I have an array of regular expressions strings. One of them must match any strings found in a given java file.
This is the regex string I have so far: \"(\\\")
In Java you can use this regex to match all escaped quotes between " and ":
boolean valid = input.matches("\"[^\"\\\\]*(\\\\.[^\"\\\\]*)*\"");
Regex being used is:
^"[^"\\]*(\\.[^"\\]*)*"$
Breakup:
^ # line start
" # match literal "
[^"\\]* # match 0 or more of any char that is not " and \
( # start a group
\\ # match a backslash \
. # match any character after \
[^"\\]* # match 0 or more of any char that is not " and \
)* # group end, and * makes it possible to match 0 or more occurrances
" # match literal "
$ # line end
RegEx Demo