Re: ereg_replace for whitespace?
| From: | Hans H. Anderson | Date: | Mon, 21 Aug 2000 22:22:03 +0000 |
| Subject: | Re: ereg_replace for whitespace? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12841@lists.php.net to get a copy of this message | ||
Jeremy,
I'm not sure why you are escaping the space, I think it will work without
it. Am I missing something?
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.