You are here: Re: regexp help please « PHP Programming Language « IT news, forums, messages
Re: regexp help please

Posted by Disco Octopus on 11/18/78 11:43

Chung Leong wrote:
> Justin Koivisto wrote:
>> Disco Octopus wrote:
>>> Hi,
>>>
>>> I think I am need of a regular expression with regards to a str_replace
>>> need that I have...
>>>

<....>

>>
>> You would need to use both a zero-width negative look-ahead and a
>> zero-width negative look-behind with prel style regex...
>>
>> <?php

<great stuff>

>> ?>

>
> \r, \n, \t are covered by \s already, so there is no need to specify

<more great stuff>

>
> $search = array('`\{(?!\s)`', '`(?<!\s)\}`');
> $replace= array('{ ', ' }');
> $s=preg_replace($search,$replace,$s);

Thanks very much Juston and Chung. This works like a charm for me, and is
hugely appreciated.

--
if it itches, it will be scratched

 

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

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