FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » reduce all spaces to one
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: reduce all spaces to one [message #176901 is a reply to message #176896] Fri, 03 February 2012 20:30 Go to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma:
Senior Member
Am 03.02.2012 20:03, schrieb John:
> Hello everybody,
>
> what would be in PHP the equivalent of the VB .NET statement
>
> Text = Regex.Replace(Text, "[ ]+", " ")
>
> in order to reduce to one all the spaces between words (chr(32)) ???
>
> Thanks for the hints.
>
>
Interactive test:

php > echo ereg_replace('[ ]+', ' ', 'here are some spaces ');
here are some spaces
php >

It works just fine, unfortunately these functions are marked deprecated. I find the
PCRE escape sequences hard to read.

/Str.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Check email
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 02:48:24 GMT 2024

Total time taken to generate the page: 0.04706 seconds