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)
Try this:
re.sub(r'\[\d+\]', '', 'something.something[0].somethingelse[21].blah')
import re
p = re.compile(r'\[[0-9]+\]')
s = 'something.something[0].somethingelse[21].blah'
print p.sub('', s)
this should work
\[\d*\]
and replace with ""
精彩评论