[Tutor] Help with re module maybe?

Jacob S. keridee at jayco.net
Sat Nov 20 02:55:52 CET 2004


Okay,

    say I have a string "x**2+sin(x**2+2*x)" and I want to split it at the
addition sign. However, I don't want to split it at the addition signs
inside the parenthesis. How do I go about doing this?

Goes something along the lines

a = a.split("+") # if and only if + not inside parenthesis

That should be enough information to help...
I think the re module might help. Any insights as to a good walkthrough of
the re module would be helpful. If you have any suggestions, or would like
to give me a more detailed way to do this (maybe a specific place in the re
module?)

Thanks in advance,
Jacob Schmidt



More information about the Tutor mailing list