How to use regex with different pattern in a multiline string in python
str1 = ''''
interface is up
admin state is up
mtu is 1500
'''
str2 = 'interface is up admin state is up'
pat = re.compile(r"interface is ([A-za-z]+) admin state is ([A-za-z]+)")
matches = pat.finditer(str2)
for match in matches:
print match.group()
print match.group(1)
print match.group(2)
the above regex pattern works for str2 (which doesn;t have newline) but not for str1 which has the same text but with newline.
I tried using re.M as well but that also doesn't seem to work.
I wanted to filter the interface status, admin status and mtu with different patterns on a multiline string.