I have a strange 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, UTF8 bounds does not work. I get
Error: 0 Result:
In most servers, everything works fine:
Error: 0 Result: This is a test_replaced text
It seems that the problem is related to word boundary when I use \b and the code works.
Both servers use php 5.2.13. Any clues what might be wrong and how to get around this?
php regex
freediver Jan 24 '11 at 12:22 2011-01-24 12:22
source share