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.
You could use positive lookbehind,
(?<=\))(\")
DEMO
It searches for the " just after ). If it founds any, then the corresponding double quotes would be matched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With