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

Popular posts from this blog

php - URL redirection after form submitted without inherited params -

c# - ReportViewer control - axd url -

c# - must be a non-abstract type with a public parameterless constructor in redis -