Reputation: 1107
I have a string as follows:
something.something[0].somethingelse[21].blah
I want to replace all the [*] section with an empty string so that I end up with a string like this:
something.something.somethingelse.blah
(I'm doing this in Python if that makes any difference)
Upvotes: 0
Views: 487
Reputation: 4510
import re
p = re.compile(r'\[[0-9]+\]')
s = 'something.something[0].somethingelse[21].blah'
print p.sub('', s)
Upvotes: 4
Reputation: 724182
Try this:
re.sub(r'\[\d+\]', '', 'something.something[0].somethingelse[21].blah')
Upvotes: 6