Variable in Regex

Christian von Essen christian at
Sat Mar 27 22:17:34 CET 2004

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:"%s" % var, StrinToMatch)
or even simpler:, StringToMatch)

More information about the Python-list mailing list