http://qs1969.pair.com?node_id=1021643


in reply to Replacing whitespaces with a regex

When you have the time read perlre

If you're in a rush... skip down to the section on "Quantifiers". TIMTOWTDI. Pick the way which you think you'll stand the best chance of understanding 3 weeks or 3 months from now when you're asked to tweak your code.

Both:

$work =~ s/\s+$/ /; # more than once

and

$work =~ s/\s{2,}$/ /; # at least twice

should work.

Replies are listed 'Best First'.
Re^2: Replacing whitespaces with a regex
by soonix (Canon) on Mar 04, 2013 at 14:16 UTC

    that should read "once or more" instead of "more than once"

    ++ anyway :-)