The first half of the code matches the word Look successfully. The second half matches the word Look with one copyright sign in place of an 'o'. The REGEX will not match using the copyright sign! Why doesn't this work?!!
In addition to the copyright sign, I've tried the cents sign and it also will not match. I've copy-pasted the REGEXs and strings below into Regex Coach (a REGEX tester) and they do match so the REGEXs are syntactically fine. I'm using PCRE 7.3 and PHP 5.2.5.
Here's the output:
In addition to the copyright sign, I've tried the cents sign and it also will not match. I've copy-pasted the REGEXs and strings below into Regex Coach (a REGEX tester) and they do match so the REGEXs are syntactically fine. I'm using PCRE 7.3 and PHP 5.2.5.
Code:
<?PHP
$iOffset = 0;
echo '<br> try simple regex';
$usethis = '/([L][o][o\xA2\xA9\x80][k])/ixu'; // Hex for cents, copyright and euro signs
$Str = 'Look up my friend';
echo '<br> $str=';
var_dump($Str);
$rtcode = preg_match_all($usethis, $Str, $TempArray, PREG_OFFSET_CAPTURE, $iOffset);
echo ' <br> $rtcode=' . $rtcode;
if (!$rtcode) echo '<br> NO match';
if ($rtcode)
{ //preg_match returns $TempArray
echo '<br> simple regex matched! $TempArray=';
var_dump($TempArray[0]);
}
echo '<br> try matching copyright sign -hex A9';
$usethis = '/([L][o][o\xA2\xA9\x80][k])/ixu';
$Str = 'Lo©k up my friend';
echo '<br> $str=';
var_dump($Str);
$rtcode = preg_match_all($usethis, $Str, $TempArray, PREG_OFFSET_CAPTURE, $iOffset);
echo ' <br> $rtcode=' . $rtcode;
if (!$rtcode) echo '<br> NO match';
if ($rtcode)
{
echo '<br> simple something matched! $TempArray=';
var_dump($TempArray[0]);
}
?>
Here's the output:
Code:
try simple regex
$str=string(17) "Look up my friend"
$rtcode=1
simple regex matched! $TempArray=array(1) { [0]=> array(2) { [0]=> string(4) "Look" [1]=> int(0) } }
try matching copyright sign -hex A9
$str=string(17) "Lo©k up my friend"
$rtcode=0
NO match