.net - Regex to get content in the last occurrence of brackets in the most outer level -


i have string: example(123) (example (123))

i'm trying string in bold. have regex: (?<=().+?(?=))

the regex works of time text in brackets, not when there's more 1 occurrences nested brackets.

please advise how can fix this.

thanks!

you need recursive regex proper matching. 1 work:

\(\w+\s*(?r)*[^()]*\) 

regex101 test

issues:

  • with 1 pattern matching outer parentheses.
  • it not anchored end of string. don't know how can achieve it. need grab last match.

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -