Re: Re: split on whitespace, preserving whitespace... (a rephrase of the question)

From: Date: Fri, 20 Jul 2001 21:27:12 +0000
Subject: Re: Re: split on whitespace, preserving whitespace... (a rephrase of the question)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58977@lists.php.net to get a copy of this message
In article <99563838501@207.155.121.134>, garth@utmail.to (Garth Dahlstrom) wrote: > > $sometext2split = "hello world with a lot of whitespaces!"; > > $myarray = preg_split ("/\s+/",$sometext2split); > > > > you should get > > $myarray := ['hello', 'world', 'with', 'a', > > 'lot', 'of', 'whitespaces!'] > > That's not what I'm after though.... <snip> > I'd be happy if I could even get: > $myarray = ["hello ", "world ","with ","a > ","lot ", > "of ","whitespaces!"] > > 'cause I could spell check based on trimming the entry. Maybe you've already tried this and rejected this for some reason, but my inclination would be to split on "\b" (the non-character boundary between a "\s+" next to a "\w+"). -- CC

« previous php.general (#58977) next »