Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Regex help
June 22, 2007, 2:27 pm
rate this thread
doubled. The space between characters is one instead of zero, and the
space between words is two instead of one.
I am trying to create a regular expression that replaces the single
space between the characters in the words with no space. Something
Obviously, the above code doesn't do the trick, but that is the idea.
Can someone please show me the way? Thank you.
Re: Regex help
$strText = preg_replace('/\s\s+/', ' ', $strText);
which makes all multiple spaces into a single space, leaving those
with just one untouched for speed
$strText = str_replace( ' ',' ',$strText );
which converts doubles to singles, str_replace is fastest.