How can python regular expressions not return unmatched group

clipboard.png

use reg ="(? < = mileage). (re.findall: km | km (?! /) | (em: km | km (?! /). (? = mileage)"
the method is re.findall

the text above is input
the list below is output

for example, for the first one, I only need to take 34km
, for example, for the second one, I only need to take 60 kilometers

. How can

solve this problem at the level of regular expressions?


p = re.compile('()?.*?(?P<data>\d+(?:|km))(?(1).*?|.*?)')
print(p.search(line).group('data'))
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e988be-5c500.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e988be-5c500.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?