Reputation: 1980
I have a string which is shown below:
a = 'steven (0.00030s ). prince (0.00040s ). kavin (0.000330s ). 23.24.21'
I want to remove the numbers inside ()
and the brackets and want to have it like this:
a = 'steven prince kavin 23.24.21'
Upvotes: 1
Views: 71
Reputation: 82755
Use re.sub
Ex:
import re
a = 'steven (0.00030s ). prince (0.00040s ). kavin (0.000330s ). 23.24.21'
print(re.sub(r"(\(.*?\)\.)", "", a))
Output:
steven prince kavin 23.24.21
Upvotes: 3