Reply to Re: Regex help

Your name:

Reply:


Posted by aquaren on 06/22/07 14:54

On Jun 22, 9:49 am, shimmyshack <matt.fa...@gmail.com> wrote:
> On Jun 22, 3:44 pm, shimmyshack <matt.fa...@gmail.com> wrote:
>
>
>
>
>
> > On Jun 22, 3:27 pm, aqua...@cox.net wrote:
>
> > > I am parsing some text files that have all the spacing between words
> > > 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
> > > like preg_replace('/.\s.','',$string).
>
> > > Obviously, the above code doesn't do the trick, but that is the idea.
>
> > > Can someone please show me the way? Thank you.
>
> > you mean
> > $strText = preg_replace('/\s\s+/', ' ', $strText);
> > which makes all multiple spaces into a single space, leaving those
> > with just one untouched for speed
> > or
> > $strText = str_replace( ' ',' ',$strText );
> > which converts doubles to singles, str_replace is fastest.
>
> sorry I didn't quite understand, what yuo want is to kill a single
> space wherever it is found - once.
> $strText = str_replace( ' ','',$strText );
> job done, no spaces in between characters, and only one in between
> words, sorry should have read more carefully!- Hide quoted text -
>
> - Show quoted text -

that's what i would have thought, but str_replace( ' ','',$strText )
removes all the spaces,
not just the single space.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация