import rerx = r"[0-9]+(?:st|[nr]d|th)"s = "April, 23rd June 1st May 2nd"print(re.findall(rx, s, flags=re.I))
Standard input is empty
['23rd', '1st', '2nd']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!