Re: ereg_replace for whitespace?

From: Date: Mon, 21 Aug 2000 23:30:38 +0000
Subject: Re: ereg_replace for whitespace?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12843@lists.php.net to get a copy of this message
Hi Hans, Hans wrote: > I'm not sure why you are escaping the space, I think it will work without > it. Am I missing something? Unless I'm wrong, it is because you are using " (double quotes) and I used ' (single quotes). ereg_replace('\ +', ' ', $userd[fname]); is not the same thing as ereg_replace(' +', ' ', $userd[fname]); But, you are correct, tabs are white space too. To whom this may concern, you may also want to fill this regex full of other characters that you want to turn into single spaces.. I can think of about 127+ of them <wink> :) Take care, -jeremy brand _______________________________________________________________________ GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9 _ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more __ > Jeremy, > > > I'd do this: > > $string = ereg_replace("[\t ]+"," ",$string); > > Tabs are whitespace, too, and I've had trouble with them. > > Hans > > On Mon, 21 Aug 2000, jeremy brand wrote: > > > This is probably what you want. > > > > ereg_replace('\ +', ' ', $$userd[fname]); > > > > So I need to remove all traces of whitespace from a string except for > > > single whitespaces... > > > > > > Example: > > > from "this is too much whitespace you see " > > > to "this is too much whitespace you see " > > > the latter being the desired string > > > > > > I was given > > > $fname = ereg_replace("\s+", " ", $userd[fname]); > > > as a suggestion, however it removes all 's'es from the string. > > Hans Anderson ~ me@hansanderson.com > PO Box 426, Missoula, MT 59806 | PHP, Search Engines, SQL > (800)397-9116 / (406)549-6524 | Databases, Flash Multimedia, > http://www.hansanderson.com | Killer Audio Production, > http://www.goofiness.com | Minty Fresh Breath. > >

« previous php.general (#12843) next »