in reply to Problem using value of variable in a regular expression

You might also consider using quotemeta or the \Q and \E operators.

My other thought here, because you don't appear to need the power of a regular expression (you are just looking to see if one string contains another), index will give you that information with much less overhead.

They say that time changes things, but you actually have to change them yourself.

—Andy Warhol