Reputation: 1654
I have tried
[^\(]\(.*\)
but in a string like
Tamara(PER) Jorquiera
The pattern returns
a(PER)
How can I get only the text inside parenthesis, assuming the open and close parenthesis occur once?
Upvotes: 0
Views: 49
Reputation: 13640
[^\(]\(.*\)
It matches any character that is not (
(a
in the example).. and a literal (
then everything till )
You can use the following:
\([^)]*\) // this will match only the text between parentheses
// including parantheses
If you want only the text use lookahead and lookbehinds:
(?<=\()[^)]*(?=\))
See DEMO
Upvotes: 1