Do you have a question? Post it now! No Registration Necessary. Now with pictures!
June 16, 2006, 3:50 pm
rate this thread
I have this test code...
$_str = "testing that'S supposed to work!"; // Notice the CAP 'S, this
is the key!
$suffixes = "'S";
$str = preg_replace("/(\w)($suffixes)\b/e", '"$1".strtolower("$2")',
It gives me this...
TESTING THAT's SUPPOSED TO WORK!
Notice the SLASH?
I don't want the slash. Beyond that, this does what I want it to do.
Please understand, this code is for example only. The question focuses
around the preg_replace(), not on how I get/create "$_str"
Re: PHP preg_replace
Unclear to me what purpose that statement serves. Ie. does it benefit
you to state it?
Seems interesting to me, too. Evidently, php assumes that the inner
strings will be single quote delimited and pre escapes the match
strings. To fix, swap the single and double quotes:
'"$1".strtolower("$2")' => "'$1'.strtolower('$2')"
Csaba Gabor from Vienna