Re: [Tutor] Is it possible to load variable into a regex string?

2005-04-27 Thread Danny Yoo
On Wed, 27 Apr 2005, Tom Tucker wrote: > Hello all! I am trying to pass a variable to my re.compile string (see > broken example below). Is something like this possible? Thanks! > > regexstring = 'H\sb' > textstring = 'BLAH blah' > match = re.compile((%s) % (regexstring)) # ? Hi Tom, Ah, I t

[Tutor] Is it possible to load variable into a regex string?

2005-04-27 Thread Tom Tucker
Hello all! I am trying to pass a variable to my re.compile string (see broken example below). Is something like this possible? Thanks! regexstring = 'H\sb' textstring = 'BLAH blah' match = re.compile((%s) % (regexstring)) # ? if match.search(line): print "I found it!" Tom ___