How do i find the first un-escaped quotes in Java?

You may try this regex to find first un-escaped quote,

^[^"\\]*?(?:[\\]{2})*(")

Demo,,, in which I intended to capture the first unescaped quote to group 1 (\1 or $1).

And for finding the index of the quote( captured group 1), you will need to retrieve the value,

matcher.start(1)

Leave a Comment