I have a file that looks like this:
foo: 11.00 12.00 bar 13.00 bar: 11.00 12.00 bar foo: 11.00 12.00
and would like to extract all the numbers in the lines starting with the keyword "foo:". Expected Result:
['11.00', '12.00', '13.00'] ['11.00', '12.00']
Now it is easy if I use two regular expressions, for example:
if re.match('^foo:', line): re.findall('\d+\.\d+', line)
but I was wondering if it is possible to combine them into one regular expression?
Thanks for your help, MD
source share