import re test1 = 'AB_x-y-z_XX1234567890_84481.xml'result = re.search('[^_]+_[^_]+\.xml$', test1, re.I)if result: print(result.group())
Standard input is empty
XX1234567890_84481.xml
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!