Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove text between parentheses

# credit to the Stack Overflow user in the source link
>>> import re 
>>> x = "This is a sentence. (once a day) [twice a day]"
>>> re.sub("[([].*?[)]]", "", x)
'This is a sentence.  '
Comment

remove all parentheses from string python

>>> table = str.maketrans({"(":None, ")":None})
Comment

remove all parentheses from string python

>>> table = str.maketrans(dict.fromkeys("()"))
>>> string1 = '(this) (is) (a) (test)'
>>> string1.translate(table)
'this is a test'
Comment

PREVIOUS NEXT
Code Example
Python :: how to sort dictionary in ascending order by sorted lambda function in python 
Python :: how to link button to the urls in django 
Python :: re.search() 
Python :: 2d array row and column 
Python :: filter lambda python 
Python :: python library to convert decimal into octal and hexadecimal 
Python :: NumPy flip Syntax 
Python :: python how to replace a string in a list 
Python :: get length of string python 
Python :: python requests response 503 
Python :: how to exit a function python 
Python :: Math Module degrees() Function in python 
Python :: python split by list 
Python :: python destructure object 
Python :: read dict txt python 
Python :: python choose function 
Python :: doctest example in python 
Python :: check if digit or alphabet 
Python :: values missing comparing datasets 
Python :: displace items in array python 
Python :: sys module in python 
Python :: for in list start with index python 
Python :: python status code to string 
Python :: First Python Program: Hello World 
Python :: map to numpy array 
Python :: python create valid filename from string 
Python :: get processor model in python 
Python :: how to get ping from computer IN PYTHON 
Python :: how to change the main diagonal in pandas 
Python :: flask production server 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =