Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

regex name extract

TITLE = r"(?:[A-Z][a-z]*.s*)?"
NAME1 = r"[A-Z][a-z]+,?s+"
MIDDLE_I = r"(?:[A-Z][a-z]*.?s*)?"
NAME2 = r"[A-Z][a-z]+"

re.findall(TITLE + NAME1 + MIDDLE_I + NAME2, string)
#['Moe Szyslak', 'Burns, C. Montgomery', 'Rev. Timothy Lovejoy', 
# 'Ned Flanders', 'Simpson, Homer', 'Dr. Julius Hibbert']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #extract
ADD COMMENT
Topic
Name
4+5 =