icykof
icykof

Reputation: 53

c# regex to capture everything between 2 double-quotes, escaped double-quote included

I am getting trouble writing a regex in C# that basically captures everything between 2 double quotes. If that group contains escaped double-quote, they would be captured as well. After reading the regex wiki I still haven't been able to write one that completely does the job.

There is a coma character between the different matches.

The following string:

 "first \"value\\\\", "second, value", "third value"

needs to give the following matches:

Thanks for your help!

Upvotes: 0

Views: 238

Answers (1)

Arpit Gupta
Arpit Gupta

Reputation: 1277

This regex should solve your purpose -

str = Regex.Replace(str, @"(""[^""\\]*(?:\\.[^""\\]*)*"")|", "$1");

Upvotes: 2

Related Questions