I am not sure I understand your question.
What do you mean by "the regex string"?
The options will work on whatever you pass to them.
The regex pattern is applied to whatever is the bound value,
the left hand side of the =~ op.
Your modifiers, the trailing "sm" in "//sm" don't care
where the bound value comes from.
The 's' means that '.' matches '\n', the 'm' means
that '^' and '$' see the '\n's in your string and match
beside them. Then only \A and \Z anchor at the beginning
and end of your string.
When you speak of genericity, I think you might be
considering using $some_variable for your PATTERN.
Beware of having a null string as your PATTERN.
When you do you get the previous PATTERN which wasn't
hidden in an narrower scope. This is not apt to be what
you want.
I may just be seeing myself
(psych or metafizz or both? I don't know)
but I think you are doing well. The binding and
the matching of regular expressions can be an unusual
concept to wrap your mind around.
It is a large swiss army chain saw in itself, learn it
bit by bit.
Go at it with a calm mind.
|