如何获取格式为(A(B(C))的regex文本字符串



我已经知道regex不完全适合提取递归嵌套的信息,但这种模式不会更深入,因此我想知道简单的regex是否可以完成这项工作。

如何提取some text A,some text Bsome text C,如果它们的格式为

some text A ( some text B ( some text C))

请注意,在某些情况下可能只有

some text A ( some text B)

您可以使用以下模式:b[^()]+b

参见Regex Demo

  • bisword boundary
  • [^()]+匹配除"("one_answers"),

最新更新