Home Posts Topics Members FAQ
Post your question to a community of 470,591 developers. It's quick & easy.
In Perl in can put a scalar variable in a regex as the pattern. for example: m/$var/ where $var contains the string I want to match Is there a way to do this in Python?
J Hamilton wrote: In Perl in can put a scalar variable in a regex as the pattern. for example: m/$var/ where $var contains the string I want to match Is there a way to do this in Python? For example: re.search("%s" % var, StrinToMatch) or even simpler: re.search(var, StringToMatch)
Replies have been disabled for this discussion.