Z
Zhao Yi
How can I change a string to regular expression? Take this method for an
example:
def match(pattern)
...
end
This method accepts one parameter as a regular expression pattern, when
I invoke this method by
match(/.../)
it works fine. But if I invoke this method by
param="/.../"
match(param)
it doesn't work as expected. It seems that the string is different with
the regular expression. If the pattern stored in a string variable, how
can I use it?
thanks.
example:
def match(pattern)
...
end
This method accepts one parameter as a regular expression pattern, when
I invoke this method by
match(/.../)
it works fine. But if I invoke this method by
param="/.../"
match(param)
it doesn't work as expected. It seems that the string is different with
the regular expression. If the pattern stored in a string variable, how
can I use it?
thanks.