<?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]);
}
?>
preferences:
65.18 ms | 402 KiB | 5 Q