Re: Use variable in regular expression

vbr at vbr at
Thu Aug 2 13:34:08 CEST 2007

> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
> I can't figure out the
> syntax of inserting the "^" into the regex. 

yesterdayRE = re.compile("^"+yesterday_date)
should work (assuming yesterday_date is a string), but for that simple tests you may also try e.g.


(with both filename and yesterday_date being strings).


More information about the Python-list mailing list