in reply to Regular Expressions: Removing 'only' single spaces from a string
Probably not very efficient, but the best I can come up with at short notice:
$str =~ s/(\S) (\S)/$1$2/g;Update:See Roy Johnson's comment above on Trix606's similar snippet. Code fixed for single spaces at start and end of string:
s/(\S|^) (\S|$)/$1$2/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular Expressions: Removing 'only' single spaces from a string
by BioBoy (Novice) on Oct 20, 2005 at 23:25 UTC | |
by GrandFather (Saint) on Oct 20, 2005 at 23:31 UTC |