But the lookahead solution is preferable.$string =~ s/(\S|^)\s(\S|$)/$1$2/g;
In reply to Re^5: Regular Expressions: Removing 'only' single spaces from a string
by Roy Johnson
in thread Regular Expressions: Removing 'only' single spaces from a string
by BioBoy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |