Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 perusing the Monastery: (11)
As of 2018-09-18 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (156 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!