Re: Re: split on whitespace, preserving whitespace...
| From: | Garth Dahlstrom | Date: | Fri, 20 Jul 2001 14:33:32 +0000 |
| Subject: | Re: Re: split on whitespace, preserving whitespace... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-58907@lists.php.net to get a copy of this message | ||
The workstation I'm on is only running 4.0.4...
perhaps it's time to upgrade. :)
I'll try it again.
On Fri, 20 Jul 2001 10:30:18 -0400 "Jack Dempsey" wrote:
> Actually, it does. I just ran it again with that exact code. What
> version of php are you running?
> Here's a direct copy/paste of what I get:
>
> <code>
> <?
> $text = "This contans white space .";
> $matches = preg_split("/(\s+)/",$text,-1, PREG_SPLIT_DELIM_CAPTURE);
> echo "<pre>[$text]<br>[".
> implode('',$matches)."]</pre>";
> ?>
> </code>
>
> <ouput>
> <pre>[This contans white space .]<br>[This contans white space
> .]</pre>
> </output>
>
> Are you running php >= 4.0.5?
>
> jack
> -----Original Message-----
> From: Garth Dahlstrom [mailto:garth@utmail.to]
> Sent: Friday, July 20, 2001 10:06 AM
> To: dabigdemp@hotmail.com
> Cc: php-general@lists.php.net; james@towntalk.co.uk
> Subject: Re: [PHP] Re: split on whitespace, preserving whitespace...
>
> On Fri, 20 Jul 2001 09:32:00 -0400 "Jack Dempsey" wrote:
>
> >
> > $text = "This contans white space .";
> > $matches = preg_split("/(\s+)/",$text,-1, PREG_SPLIT_DELIM_CAPTURE);
> > echo implode('',$matches);
>
> Nope that doesn't do it.
> here's the test:
> echo "<pre>[$text]<br>[".
> implode('',$matches)."]</pre>";
>
> here's the output:
> [This contans white space .]
> [Thiscontanswhitespace.]
>
> If it were working the two lines should be identical.
>
>
> Northern.CA ===--
> http://www.northern.ca
> Canada's Search Engine
>
> > -----Original Message-----
> > mmm... yeah... That's what I had before
> > (acutally I was using the alias split)...
> > it does NOT however preserve the areas
> > of white space.
> >
> > Instead the target of:
> > > > $wordsarr = ('This',' ','contans','
> > > > ','white',' ','space','
> > ','.')
> >
> > You get:
> > > > $wordsarr =
> > > > ('This','','contans','','white','space','','.')
> >
> > which has totally destroyed the whitespace I'm trying to
> > keep intacted.
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
Northern.CA ===--
http://www.northern.ca
Canada's Search Engine