http://www.perlmonks.org?node_id=984575


in reply to Re: Removing extra spaces
in thread Removing extra spaces

Close, just drop the \s? and it works.

$ perl -E '$s="2 0 1 2 - 7 - 2 7 9 : 3 7 : 3 1"; $s =~ s/\s\s?(\S)/$1 +/g; say $s' 2012-7-279:37:31 $ perl -E '$s="2 0 1 2 - 7 - 2 7 9 : 3 7 : 3 1"; $s =~ s/\s(\S)/$1/g; + say $s' 2012-7-27 9:37:31