Re: reduce all spaces to one [message #176908 is a reply to message #176903] |
Sat, 04 February 2012 21:26 |
John
Messages: 18 Registered: September 2010
Karma:
|
Junior Member |
|
|
Am 04.02.2012 15:41, schrieb Thomas 'PointedEars' Lahn:
>
> It should be noted that if your question was understood literally, the
> solutions presented so far would be wrong. \s would match too many
> different characters, as it stands for *white-space* in PCRE, _not_ only the
> space character. In order to reduce only all consecutive *space* characters
> to one space character, you need to write
>
> echo preg_replace('/ +/', ' ', "here are some \n spaces ");
>
> Note that the newline, which is white-space too, is preserved here.
>
in fact, just by 'accident' the 'regex' solutions fits perfectly in what
I have to do next, i.e. feed the text through an 'explode' statement,
which takes ' ' as separator.
|
|
|