Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by kyle (Abbot)
on Nov 06, 2007 at 15:57 UTC ( #649240=note: print w/replies, xml ) Need Help??


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

my $RE = qr! \b ( SA | NV | LTD | CO | LLC ) \b !ix ; my $s1 = 'Bobs Warehouse SA LTD'; my $s2 = 'Jims Fine Wines CO LLC'; 1 while $s1 =~ s{$RE}{}; 1 while $s2 =~ s{$RE}{}; print "[$s1]\n[$s2]\n"; __END__ [Bobs Warehouse ] [Jims Fine Wines ]
  • Comment on Re: regexp - repeatedly delete words from end of string with words in alternation
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649240]
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 2019-11-12 04:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (64 votes). Check out past polls.

    Notices?