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

html5 - What is breaking my page when printing? -

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

ajax - PHP/JSON Login script (Twitter style) not setting sessions -