import re p = re.compile(r'((?<!\d)\d{2}(?!\d)|(?!.*(?<!\d)\d{2}(?!\d)))')r = p.search('wqd123dsel78ffgr')print r.groups()
Standard input is empty
('78',)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!