regex - How to use in python regular expression -
i utilize numeric variable regular look part.
what should if want utilize variable in part (?p<hh>\d)
i want output lines contain input number.
using string interpolation:
m = re.compile(r'\d{%d}:\d{%d}' % (var1, var2))
if vars aren't integers may need convert types so:
m = re.compile(r'\d{%d}:\d{%d}' % (int(var1), int(var2)))
python regex
No comments:
Post a Comment