[thelist] converting whitespace to single space between printable characters

Ivo P ipletikosic at gmail.com
Thu Dec 8 09:47:04 CST 2005


how about?

$text_with_many_spaces= preg_replace ("/\s/", " ", $text);
$text_with_less_spaces = ereg_replace ( " +", " ", $text_with_many_spaces );

On 12/7/05, Matt Warden <mwarden at gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Alex Beston wrote:
> > Hi evolt
> >
> > Im trying to reduce the whitespace between printable characters to a single space.
> >
> > What i want to do is get all of the the words in a text so as to make a
> > histogram of word frequencies.
> >
> > Im doing this by exploding the string and using space as the delimiter.
> > that only works in so far as words that are separated by spaces. so i
> > find that i get words that have been yoked together since they were
> > seperated with a return character.



More information about the thelist mailing list