0

I would like to get the string inside a pair of parenthesis.

For example, my string is Here is my string (This is the string in parenthesis (and this is the second layer)).

I want to get This is the string in parenthesis (and this is the second layer))

I tried to use (?<=\()(.*?)(?=\)) and I got['and this is the second layer'].

What is the correct approach?

Thanks.

John
  • 521
  • 1
  • 3
  • 15
  • If I'm not mistaken, you want `This is the string in parenthesis (and this is the second layer)` without the additional parenthesis in the end, yes? – Zionsof Apr 20 '20 at 07:37
  • yes, you are correct. – John Apr 20 '20 at 07:42
  • Well, the question was closed due to being a duplicate, but I'm not sure the other answers work well for your situation. You can do: `s.split("(", 1)[1].rsplit(")", 1)[0]` – Zionsof Apr 20 '20 at 07:44

0 Answers0