Search
 
SCRIPT & CODE EXAMPLE
 

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']
Comment

PREVIOUS NEXT
Code Example
Python :: python get the intersection of two lists 
Python :: check if something is nan python 
Python :: all frequency offset in pandas 
Python :: how to check if python is installed 
Python :: python join dict 
Python :: what is a slug 
Python :: generate rsa key python 
Python :: python random walk 
Python :: how to create staff account in django 
Python :: python turtle 
Python :: matplotlib twinx legend 
Python :: how to find the transpose of a matrix in python 
Python :: progress bar python text 
Python :: sns how to change color if negative or positive 
Python :: semicolon in python 
Python :: python convert input into lowercase 
Python :: get random number positive or negative python 
Python :: pandas resample groupby 
Python :: dataframe to pandas 
Python :: how to stop all pygame mixer sound 
Python :: thread syntax in python 
Python :: get weekday from date python 
Python :: pandas hist normalized 
Python :: Drop multiple columns by name 
Python :: pandas dataframe get first n rows 
Python :: python insert path 
Python :: rename column in pandas with second row 
Python :: print a string with spaces between characters python 
Python :: pandas.core.frame.DataFrame to pandas.core.series.Series 
Python :: python datetime greater than now 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =