Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 romping around the Monastery: (3)
As of 2020-07-05 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?