Re: [DONE] Substr by words

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux