I have two lists:
list_1 = ["TP", "MP"]
list_2 = ["This is ABC12378TP0892S3", "This is XYZ12378MP0892S3"]
I want take elements from list_1 and search in strings of list_2. If found (for example TP is present in list_2's first string, MP is present in list_2's second string), remove what is to the right of TP, MP etc. and insert space to left of it.
I tried the below with re, but it is removing only the right part:
[ re.sub(r'(' + '|'.join(list_1) + ')\d+', r'\1', string) for string in list_2 ]