in reply to regex with arrays and variables
That trailing "|" allows an empty match.(foo|bar|baz|)
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
|
|---|