Can anyone provide guidance on why the following regex is not working?
project = 'AirPortFamily'
line = 'AirPortFamily-1425.9:'
if re.findall('%s-(\d+):'%project,line):
print line
EXPECTED OUTPUT:-
AirPortFamily-1425.9
You should match the optional groups of digits preceded by a dot:
if re.findall(r'(%s-\d+(?:\.\d+)*):'%project,line):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With