在Java中,您可以使用此正则表达式匹配
"和之间的所有转义引号
":
boolean valid = input.matches(""[^"\\]*(\\.[^"\\]*)*"");使用的正则表达式是:
^"[^"\]*(\.[^"\]*)*"$
分手:
^ # 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
正则演示



