You are here: Re: PHP preg_replace « PHP Programming Language « IT news, forums, messages
Re: PHP preg_replace

Posted by Csaba Gabor on 12/16/68 11:50

otrWalter@gmail.com wrote:
> I have a very specific need.
> Too long to get into what and why here (If you please).

Unclear to me what purpose that statement serves. Ie. does it benefit
you to state it?

> 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")',
> $_str);
> echo $str;
> exit;
>
> It gives me this...
>
> TESTING THAT\'s SUPPOSED TO WORK!

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация