I’m trying to resolve a preg_replace mistery with no success, perhaps you can help me. I have this sentence:
$string = preg_replace("/\[_BEGIN_\](.*?)\[_END_\]/", '', $string);
It removes all content between any [_BEGIN_] and [_END_] meta-tags. For example applied to:
"The [_BEGIN_] quick brown [_END_]fox jumps over the lazy dog"
gives as result:
"The fox jumps over the lazy dog"
The problem is it works in my development machine (Ubuntu 9.10, PHP v5.2.10) but in my production site (Gentoo 1.6.14, PHP v5.2.5-pl1-gentoo) it fails (preg_replace returns the same input string).
There is any problem with the regex used? How can I fix this problem? How to debug it? Any clue will be welcome. Thanks.
I don’t see
\Canywhere in the list of escape sequences. Shouldn’t it be(.*?)instead of(\C*?)?