Python regex: matching a parenthesis within parenthesis

前端 未结 6 1686
滥情空心
滥情空心 2020-12-14 16:52

I\'ve been trying to match the following string:

string = \"TEMPLATES = ( (\'index.html\', \'home\'), (\'base.html\', \'base\'))\"

But unfo

6条回答
  •  清歌不尽
    2020-12-14 17:30

    Your sample is looking for open paren followed by zero or more letter w followed by close paren. You probably want to use \w instead of w, but that won't work in your case anyway, because you have non-word characters next to the open paren.

    I think you should consider splitting the string at the commas instead. What is your final objective?

提交回复
热议问题