import rerev_rx = r'((?:\d+[ .]?){5,})(?=(.{0,30}))'text="I went and I bought few tickets and ticket numbers 100000,100001 and 100002.I bought them for 200,300 and 400 USD. Box office collections were 55555555 USD"results = [ "{}{}".format(y[::-1], x[::-1]) for x, y in re.findall(rev_rx, text[::-1]) ]print(results)
Standard input is empty
['D. Box office collections were 55555555', 'cket numbers 100000,100001 and 100002', 'ets and ticket numbers 100000,100001', 'few tickets and ticket numbers 100000']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!