On Nov 28, Pedro A Reche Gallardo said: >Hi all, I would like to delete all single white spaces from a string >without deleting concatenated white spaces. An example: >$string= "I want to delete all this spaces, but this" > >The result would be: > >$string = "Iwanttodeleteallthisspacesbut this"
I suggest a negative look-behind and a negative look-ahead: $string =~ s/(?<!\s)\s(?!\s)//g; But that might take too long, since it's probably not optimized the way it should be. So I'd probably go with: $string =~ s/(\s+)/length($1) == 1 and $1/eg; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]