I have a multiline string, like this:
tt = """
some text
myvar=foo
some more text
"""
Now what i want to do is to extract the value behind 'myvar=', in this case 'foo'.
I tried like this:
import re
m = re.match('^myvar=(.*)$', tt, flags=re.MULTILINE)
if m:
print(m.group(1))
But m
is always None
. It only works with single line strings, like:
tt = 'myvar=foo'
What am I missing? I am new to python, but not to regex.