Search text with a regular expression to match outside specific characters

Posted by user228164 on Stack Overflow See other posts from Stack Overflow or by user228164
Published on 2010-03-18T16:40:19Z Indexed on 2010/03/18 16:41 UTC
Read the original article Hit count: 360

Filed under:

I have text that looks like:

My name is (Richard) and I cannot do [whatever (Jack) can't do] and (Robert) is the same way [unlike (Betty)] thanks (Jill)

The goal is to search using a regular expression to find all parenthesized names that occur anywhere in the text BUT in-between any brackets.

So in the text above, the result I am looking for is:

  • Richard
  • Robert
  • Jill

© Stack Overflow or respective owner

Related posts about regex