in reply to Re^4: Regular Expressions: Removing 'only' single spaces from a string
in thread Regular Expressions: Removing 'only' single spaces from a string

Won't work for a single space at the beginning or end of the string. To fix:
$string =~ s/(\S|^)\s(\S|$)/$1$2/g;
But the lookahead solution is preferable.

Caution: Contents may have been coded under pressure.
  • Comment on Re^5: Regular Expressions: Removing 'only' single spaces from a string
  • Download Code