3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); echo setlocale(LC_ALL, 0)."\n"; // echo setlocale(LC_ALL, "en_GB.UTF-8")."\n"; $terms = array ( //Always matches: "Label Generation", //Doesn't match when using u (PCRE_UTF8) modifier: "Receipt of Prescription and Validation of Patient Information", ); $text = "Some terms to match: ".implode(", ",$terms); $pattern = "/(".implode(")|(", $terms).")/is"; $regexps = array ( "Unicode" => $pattern."u", //Add u (PCRE_UTF8) modifier "Non-unicode" => $pattern ); echo "Text:\n'$text'\n"; foreach($regexps as $type=>$regexp) { $matches = array(); $total = preg_match_all($regexp,$text,$matches); echo "\n\n"; echo "$type regex:\n'$regexp'\n\n"; echo "Total $type matches: "; var_dump($total); echo "\n$type matches: "; var_dump($matches[0]); } ?>
Output for 4.3.0 - 5.6.28, 7.0.0 - 7.1.0
C Text: 'Some terms to match: Label Generation, Receipt of Prescription and Validation of Patient Information' Unicode regex: '/(Label Generation)|(Receipt of Prescription and Validation of Patient Information)/isu' Total Unicode matches: int(2) Unicode matches: array(2) { [0]=> string(16) "Label Generation" [1]=> string(61) "Receipt of Prescription and Validation of Patient Information" } Non-unicode regex: '/(Label Generation)|(Receipt of Prescription and Validation of Patient Information)/is' Total Non-unicode matches: int(2) Non-unicode matches: array(2) { [0]=> string(16) "Label Generation" [1]=> string(61) "Receipt of Prescription and Validation of Patient Information" }
Output for hhvm-3.10.0 - 3.12.0
Text: 'Some terms to match: Label Generation, Receipt of Prescription and Validation of Patient Information' Unicode regex: '/(Label Generation)|(Receipt of Prescription and Validation of Patient Information)/isu' Total Unicode matches: int(2) Unicode matches: array(2) { [0]=> string(16) "Label Generation" [1]=> string(61) "Receipt of Prescription and Validation of Patient Information" } Non-unicode regex: '/(Label Generation)|(Receipt of Prescription and Validation of Patient Information)/is' Total Non-unicode matches: int(2) Non-unicode matches: array(2) { [0]=> string(16) "Label Generation" [1]=> string(61) "Receipt of Prescription and Validation of Patient Information" }