What is the best way to split a string into two parts in Python from right to left until one of several characters occur?
The aim is to separate a string into two parts with a version number (beginning with either A, B or C) at the end for examples like these:
- EP3293036A1 -> EP3293036 + A1
- US10661612B2 -> US10661612 + B2
- CN107962948A -> CN107962948 + A
- ES15258411C1 -> ES15258411 + C1
My code works for splitting the string for a single character:
first_part = number.rpartition('A')[0]
second_part = number.rpartition('A')[1] + number.rpartition('A')[2]
Is there a way to have multiple arguments like ('A' or 'B' or 'C') using rpartition? Or is there a better way using regex?