java - what changes should be done to the string ""abcd"" (all double quotes should be preserved) in order to match the regular expression \"([^\"]*)\" -


the regular expression \"([^\"]*)\" matching string ""abcd"" "" "" . changes(i mean adding escape characters string) should done string such regular expression should match ""abcd""

sorry if invalid question. requirement match string given regular expression in advance.

what changes should done string such regular expression should match ""abcd""?

you can make regex match ""abcd"" adding \" both sides code, , remove () (optional), no need them. code be:

\"\"[^\"]*\"\" 

demo: https://regex101.com/r/6spoec/6

if want limit inside quotations alphabetical, can use [a-za-z].

\"\"[a-za-z]+\"\" 

demo: https://regex101.com/r/6spoec/5

if want include alphabetics, numbers , underscore _ inside quotation marks, use \w

\"\"[\w]+\"\" 

demo: https://regex101.com/r/6spoec/4

by way, careful + , *.

+ can return @ least 1 character or more while * can return 0 or more characters means * can return empty quotations """"


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -