Reputation: 305
I need to match a right bracket followed by a quote: )"
like the last two characters in this string:
He said "Free Willi (song)"
I use the following regex which indeed match them:
(?:\))(")
My problem has to do with the grouping: this regex results in two groups:
Group 1: )"
Group 2: "
I would like to avoid the first group and have only one group that includes the double quotes (because of some generic code that uses the first group only).
Is there a way to avoid the first group?
I thought I did it by using the ?:
on the left hand side of the expression, but apparently I didn't.
Upvotes: 3
Views: 68
Reputation: 174706
You could use positive lookbehind,
(?<=\))(\")
It searches for the "
just after )
. If it founds any, then the corresponding double quotes would be matched.
Upvotes: 3