PHP Matching Using Backreferences – String Function

<?
$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";
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.