I am parsing an xml file (called xml below) that has lines of two varying types:
1. <line a="a1" b="b1" c="c1">
2. <line a="a2" c="c2">
I am trying to pull a2 and c2 only from the second type, however this regular expression also captures the first type:
>>> list = re.findall('<line a="(.*)" c="(.*)">', xml)
>>> print(list)
[('a1" b="b1', 'c1'), ('a2', 'c2')]
How would I capture just the second type?
The * operator is greedy by default. Try ([^”]*) instead of (.*)