Sep-14-2019, 08:24 AM
(This post was last modified: Sep-14-2019, 08:25 AM by Gribouillis.)
I would start with this
>>> pat = re.compile(r'([@/+]\d+(?:[.]\d*)?)') >>> pat.findall('/2@3+4') ['/2', '@3', '+4']I don't think it's a good idea to look for a one liner here. You can check that the list has 3 elements, you can convert the list into a dictionary
{'@': '3', '/': '2', '+': '4'}
and check again that the dict has 3 elements. Finally you can check that the string contains nothing else with pat.sub('', '/2@3+4') == ''