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 :: sns seaborn set theme 
Python :: create pyspark session with hive support 
Python :: pandas read_csv random rows 
Python :: get video length python 
Python :: django select database for migrate 
Python :: how to make text bold in tkinter 
Python :: remove unnamed column pandas 
Python :: python sys halt 
Python :: how to get the current web page link in selenium pthon 
Python :: python condition if dataype 
Python :: python map input 
Python :: pandas sample rows 
Python :: python printing date 
Python :: python get cpu info 
Python :: matplotlib latex non italic indices 
Python :: today date python 
Python :: display text in pygame 
Python :: how to make jupyterlab see other directory 
Python :: python ctypes get current window 
Python :: how to fill na python 
Python :: heatmap(df_train.corr()) 
Python :: how to display qr code in python 
Python :: python iterate object 
Python :: python read_excel index_col 
Python :: discord command addrole python 
Python :: pandas to_csv delimiter 
Python :: python return right operand if left is falsy 
Python :: gmpy2 is prime 
Python :: matplotlib plot 
Python :: multiline input in python 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =