Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001032

Re: [PHP] Regexp From: CC Zona (cczona <email protected>)
Date: 03/29/01

In article <LHEJIKDFKMHLGMPILEDFOEFPCAAA.db <email protected>>,
 db <email protected> ("David Balatero") wrote:

> So, I guess i need a regexp to remove all the
> \n and :space: chars.

Here are some ideas:

$out=preg_replace("/\s+/","",$in); //strip whitespace

or

$out=preg_replace("/\s+/"," ",$in); //replace whitespace with single space

Note that you requested is different from your example, in which it looks
like you are simply condensing multiple newlines down into a single
newline. For that, something like this might be more appropriate:

$out=preg_replace("/(\n|\r|\r\n)+/","\n",$in);

Play around with 'em. <g>

-- 
CC

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>