in reply to How to pass regular expression as variable ?

Maybe you're confusing regular expressions and shell wildcards?

For example, NX* - as a regex - means N followed by zero or more X, which might not be what you intended.  Try .* in place of *

See perlre.  And maybe also Regexp::Wildcards, in case you rather want to specify the patterns as wildcards.  Or Text::Glob, to directly match wildcard patterns against a string.