re.sub question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

re.sub question

Is there a way to sub two different characters in one line. Here is how I did it to remove brackets from a string. formulas = re.sub("\(","",input()) formulas = re.sub("\)","",formulas).split()

30th Mar 2020, 1:22 AM
DAYLINER BAND
DAYLINER BAND - avatar
1 Answer
+ 1
import re mystring = "hello )world( just a) test(" print(re.sub("[()]", '', mystring))
30th Mar 2020, 4:51 AM
rodwynnejones
rodwynnejones - avatar