I'm trying to split the text below, so the string is split by spaces, unless the token is between quotation marks. The unexpected result is that it is also split for the . character which I do not want.
string txt = "PROGRAM \"My ETABS\" VERSION \"9.7.4\" MERGETOL 0.1";
string[] split = Regex.Matches(txt, "(\\w+|\".*?\")")
.Cast<Match>()
.Select(m => m.Value)
.Select(o => o.Replace("\"", ""))
.ToArray();
What I get:
PROGRAM
My ETABS
VERSION
9.7.4"
MERGETOL
0
1
What I need:
PROGRAM
My ETABS
VERSION
9.7.4"
MERGETOL
0.1