0

I'm using the below code to split a string based on spaces, unless that space happens inside quotation marks. How can I remove the quotation marks from the final result?

var txt = "PROGRAM \"My ETABS\" VERSION \"9.7.4\"";

string[] split = Regex.Matches(txt, "(\\w+|\".*?\")")
                      .Cast<Match>()
                      .Select(m => m.Value)
                      .ToArray();

Now I have this:

PROGRAM
"My ETABS"
VERSION
"9.7.4"

But I want this:

PROGRAM  
My ETABS
VERSION 
9.7.4
Vahid
  • 5,144
  • 13
  • 70
  • 146

0 Answers0