Note also that using \s matches more than the space the OP mentioned. In particular, s/\s+/ /g or s/\s{2,}/ /g will replace one (two) or more newlines with a space.$str =~ s/\s{2,}/ /g;
In reply to Re^2: Replace consecutive whitespaces with single whitespace
by JavaFan
in thread Replace consecutive whitespaces with single whitespace
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |