2

Possible Duplicate:
python string manipulation

Hi,

I have a string s = AX(p>q)&E(qUr)

I want to remove all characters between brackets and store in a new string like this:

new_string = AX&E

i tried doing this:

p = re.compile('\(\(*?.*?\)\)', re.DOTALL)

new_string = p.sub('', s)

but its still showing the same string. Is there any problem with the syntaX?

Jay

EDIT

Hello,

It doesn't seem to work for strings containing nested brackets, like this one: AX(p>q)&E((-p)Ur)

Is there an easier way to do so, rather than iterating each element in the string? Thanks

Community
  • 1
  • 1
Jay
  • 1,392
  • 7
  • 17
  • 44

0 Answers0