I'm using python and I want to strip some words/phrases appearing before a person's name. There's my regex, but it's doing partial matching instead of matching the exact words/phrases.
a = 'THE REVOF Joe Johnson'
pattern_prefix = r"^([MR]|[MRS]|[MISS]|[DR]|[PROF]|[EST OF]|[THE REV]|[ES OF]|[THE ESTASTE OF]|[ESTATE OF]|[THE ESTTE OF])+\s"
re.sub(pattern_prefix, ' ', a.strip(), flags=re.IGNORECASE)```
Example of input and desired output:
Mr Joe Johnson -- > Joe Johnson
EST OF Martha Jar -- > Martha Jar
THE REVOF Joe John --> REVOF Joe John; but my code is recently returning Joe John
I tried using word/phrase boundary (i.e., \b($word)\b, but I did not get the desired output.