Mega Code Archive

 
Categories / Php / Strings
 

Matching using backreferences

<? $ok_html  = "I <b>love</b> shrimp dumplings."; if (preg_match('@<[bi]>.*?</[bi]>@',$ok_html)) {     print "Good for you! (OK, No backreferences)\n"; } if (preg_match('@<([bi])>.*?</\\1>@',$ok_html)) {     print "Good for you! (OK, Backreferences)\n"; } ?>