Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: regexp - repeatedly delete words from end of string with words in alternation

by gamache (Friar)
on Nov 06, 2007 at 15:58 UTC ( #649241=note: print w/replies, xml ) Need Help??


in reply to repeatedly delete words expressed in alternation from end of string [regexp]

while (s/\s*$RE$//) {}
or
s/(\s*$RE)*$//;
will get you there without leaving trailing spaces in the finished $_. (Update: made it a little easier to read.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2018-11-20 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (220 votes). Check out past polls.

    Notices?