Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove articles from string regex

# credit to the Stack Overflow user in the source link

re.sub('(s+)(a|an|and|the)(s+)', '13', text) # leaves the residual whitespace

re.sub('s+(a|an|and|the)(s+)', '2', text) # removes the whitespace
Comment

PREVIOUS NEXT
Code Example
Python :: euclidean division in python 
Python :: python how to change an element in a multi dimensional list 
Python :: python __version__ 
Python :: pandas concatenate 
Python :: pandas rename multiple columns 
Python :: python list abstraction 
Python :: password manager python 
Python :: python largest value in list 
Python :: making a function wait in python 
Python :: convert string in list format to list python 
Python :: python get name of function 
Python :: how to delete a specific line in a file 
Python :: tkinter button command with arguments 
Python :: convex hull algorithm python 
Python :: python getter decorator 
Python :: remove special characters from string python 
Python :: python merge list into string 
Python :: case statement in pandas 
Python :: How many columns have null values present in them? in pandas 
Python :: rename key in dict python 
Python :: django form set min and max value 
Python :: ternary operator python 
Python :: small factorial codechef solution 
Python :: sum of number digits python 
Python :: find columns with missing values pandas 
Python :: python copy an object 
Python :: python cv2 get image shape 
Python :: dataframe get index name 
Python :: remove columns from a dataframe python 
Python :: opencv export image 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =