- preg_match_all: documentation ( source)
<?php $re1=".*?"; # Non-greedy match on filler
$re2="(\\[)"; # Any Single Character 1
$re3="(n)"; # Any Single Character 2
$re4="(i)"; # Any Single Character 3
$re5="(d)"; # Any Single Character 4
$re6="(:)"; # Any Single Character 5
$txt="iasduad iiabefibasdib [nid:112] oabsdo baosd [10] [n10]";
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6."/is", $txt, $matches)){ $c1=$matches[1][0]; $c2=$matches[2][0]; $c3=$matches[3][0]; $c4=$matches[4][0]; $c5=$matches[5][0]; print "($c1) ($c2) ($c3) ($c4) ($c5) \n"; }