Help with regex
#1
I'm trying to remove everything between two brackets "[" and "]".

I can remove the brackets using .replace("[","").replace("]","") from this text "[00:45]Oh, to the fact that...more text"
Where it returns "00:45Oh, to the fact that...more text"

How can I remove everything in between the brackets also so it will return...
"Oh, to the fact...more text"? I want to strip out the brackets and everything in between them.

I've tried several different ways from info that I googled but can't seem to get it. Any help would be appreciated. Thanks.
Reply
#2
re.sub(r"\[[^\[]*?\]", "", "[00:45]Oh, to the fact that...more text") for instance..
Reply
#3
(2014-12-10, 23:23)takoi Wrote: re.sub(r"\[[^\[]*?\]", "", "[00:45]Oh, to the fact that...more text") for instance..

Thanks... works perfect.
Reply

Logout Mark Read Team Forum Stats Members Help
Help with regex0