java - Not Contain REGEX -
the regex have write match single or double quoted strings (string begin single or double quoted string , end same type) , inside quote not contain other instances of type of quote.
what have far
^('|").*\1
but not know how control inside quote not contain same type of quote.
how about
pattern p = pattern.compile("^(\"[^\"]*\"|'[^']*')$");
not elegant using \1
, should job done.
Comments
Post a Comment