Python supprime le titre du nom

import re
'''
\b   # Word boundary (to match 'mr' but not 'zmr' unless specified)
(?:group|of|prefixes|that|we|want|to|remove) # example
\.   # Literal '.'
\s*  # 0 or more spaces
'''
# Ex1
prefixes = ['mr', 'smr']
regex = r'\b(?:' + '|'.join(prefixes) + r')\.\s*'
i = 'hi mr.john, smr. john, etc. Previous etc should not be removed'
i = re.sub(regex,'',i)
print(i)

# Ex2
As a regular expression this looks like r'^\w{2,3}\. ?.'
Now you can use re.sub to replace this part with an empty string.

cleaned_name = re.sub(r'(^\w{2,3}\. ?)', r'', name)
# Assert that full_name has no honorifics
assert df['full_name'].str.contains('Ms.|Mr.|Miss|Dr.').any() == False
NP