I have a string "age > 4 < 6"
I would like to get the min and max range (4 being min and 6 being max)
without order being an issue, so "age < 6 > 4" should also work just as well as "age > 4 < 6"
I currently have:
pattern = re.compile(r'(?P<min>age.*?> ?[\d+] ?)(?P<max>age.*?< ?[\d+] ?)')
address = pattern.search('age > 4 < 6')
min, max = (address.group('min'), address.group('max'))
print min, max
But this does not work for me.
I am trying to use .*? to allow min to come before max or max to come before min – but to no avail!
1 Answer