Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Replacing whitespaces with a regex

by ggoebel (Sexton)
on Mar 04, 2013 at 13:51 UTC ( #1021643=note: print w/replies, xml ) Need Help??

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.


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


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

should work.

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

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

    ++ anyway :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021643]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-06-24 17:52 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (561 votes). Check out past polls.