You are here: Re: [PHP] [DONE] Substr by words « PHP « IT news, forums, messages
Re: [PHP] [DONE] Substr by words

Posted by "Richard Lynch" on 10/31/05 08:27

On Sun, October 30, 2005 6:04 am, Marcus Bointon wrote:
> On 29 Oct 2005, at 20:41, Richard Lynch wrote:
>
>> It was probably replacing *TWO* spaces with one.
>>
>> If so, it should really be in a while loop, because there could be 3
>> or more spaces in a row, and if the goal is only single-spaced
>> words...
>
> I can hardly think of a better application for a regex:
>
> $text = preg_replace('/ */', ' ', $text);

Sure.

Now you wanna go re-write all my code that pre-dates preg_* functions
being added to PHP? :-)

Un-paid? :-) :-) :-)

Cuz I probably still do have a while(ststr(...)) str_replace() loop or
two in there somewhere from PHP3.0rc2 days...

Yes, ereg_* were in then.

But they were kinda slow and I didn't undestand Regex then.

Hell, I barely understand it now, really.

There's a certain point where the Regex expression reaches a level of
complexity that I'm just not willing to accept in my code and call it
"maintainable"

/ */ is fine, of course.

But there's lots of times when I know there must be a one-line regex
to replace 10 lines of code, but I don't WANT to use it because I'll
stumble over that one-line Regex every time I have to change it.

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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