I have a weird problem. consider this short code:
<?php
$reg = '/(?<!\pL)(test)(?!\pL)/u';
$text='This is a test text';
$replace = 'test_replaced';
$newtext = preg_replace($reg, $replace, $text);
echo "Error: ".preg_last_error()."\nResult: ".$newtext."\n";
?>
On some servers the UTF8 boundary matching does not work. I get
Error: 0
Result:
On majority servers everything works normally:
Error: 0
Result: This is a test_replaced text
There seems to be a problem with word boundary as when I use \b
instead the code works.
Both servers use php 5.2.13. Any clues what might be wrong and how to get around it?