Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: regex with arrays and variables

by NetWallah (Abbot)
on Apr 25, 2013 at 18:20 UTC ( #1030714=note: print w/replies, xml ) Need Help??


in reply to regex with arrays and variables

Your regex concat command creates a regex that looks like:
(foo|bar|baz|)
That trailing "|" allows an empty match.

This is why all elements matched.

Try removing the trailing "|". This is the canonical way to match a bunch of different things. Also, you do not need the parens, unless you are capturing.

Lastly, use a "join" instead of looping and concatenating - that will also avoid the trailing "|".

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030714]
help
Chatterbox?
jkva dusts the floor
[karlgoethebier]: Totally OT but my pleasure: Next week i'll have my first archery lesson.
[Corion]: Hi jkva!
[Corion]: karlgoethevier: Oooh, that sounds interesting! ;)
[karlgoethebier]: btw, good morning

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-10-20 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?