0

I want to write a re that accepts everything that is between parenthesis. My re is: r''\'([^&]+'\')' (ingnore the '' in the backslash)

I had to put that random character so it will accept everything except that. How can I write it so it accepts EVERYTHING including that character. Thanks.

Kevjumba94
  • 19
  • 2
  • do you know how to accept an answer? Don't worry about me and my answer, but you should go back and accept the answer for your question from last year: http://stackoverflow.com/questions/21146970/class-that-returns-arrays. It's only right. – jimhark Sep 16 '15 at 00:21

1 Answers1

0

How about:

r'\([^)]+\)'

Because you don't want to accept the close parenthesis.

Also:

(Dot.) In the default mode, this matches any character except a newline. If the DOTALL flag has been specified, this matches any character including a newline.

So:

r'\(.+\)'

Might be what you are looking for.

jimhark
  • 4,938
  • 2
  • 27
  • 28
  • That could work, but for what I'm doing there is not always a pair of parenthesis. Isn't there something for everything? – Kevjumba94 Sep 16 '15 at 00:04
  • The regex you gave will not match without a close paren, you are explicitly requiring it. – jimhark Sep 16 '15 at 00:08