I have an XML snippet like:
<CharacterBlock MinVal="-10.000000" MaxVal="15.000000" Active="1">
and I need to parse the minimum and maximum floating point values. I can’t use an XML parser like ElementTree, so I’m forced to use a regular expression.
I have written the following Python regex:
re.compile('<CharacterBlock MinVal="(?P<MinVal>-?[0-9]*\.?[0-9]*)" MaxVal="(?P<MaxVal>-?[0-9]*\.?[0-9]*)" .*?>', re.DOTALL)
which works for the above snippet. But since the XML attributes are like a dictionary, their order is not guaranteed, and sometimes I receive a snippet like:
<CharacterBlock Active="0" MaxVal="-15.000000" MinVal="-100.000000">
How do I handle this case where the order of the groups I want to match is not fixed?
can you get the two values separately ? like: