I have a situation where I have to match a pattern only when previous regex pattern matches. Both pattern are different and matchobj in different line. For exmaple,
Text:
blah blah blah MyHost="xxxx"
again blah blah blah MyIp= "x.x.x.x"
I am only interested in whats comes after MyHost
and MyIp
, I also have a requirement that MyIp
should match only when there is a match(MyHost="xxxx")
in the above line.
I am able to match both MyHost
value and MyIp
value separately but having hard time finding a logic to match both as per the requirement. Please note I am fairly new to python and tried lot of search and end up here.