Re: Variable in Regex
From: Christian von Essen (christian_at_mvonessen.de)
Date: 03/27/04
- Next message: Mark Jackson: "Re: import a modified module"
- Previous message: Roger Binns: "Re: xmlrpc, httplib and SSL"
- In reply to: J Hamilton: "Variable in Regex"
- Next in thread: J Hamilton: "Re: Variable in Regex"
- Reply: J Hamilton: "Re: Variable in Regex"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Mar 2004 22:17:34 +0100
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)
- Next message: Mark Jackson: "Re: import a modified module"
- Previous message: Roger Binns: "Re: xmlrpc, httplib and SSL"
- In reply to: J Hamilton: "Variable in Regex"
- Next in thread: J Hamilton: "Re: Variable in Regex"
- Reply: J Hamilton: "Re: Variable in Regex"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|