I want to split a string in C # that looks like
a: b: "c: d"
so that the resulting array has
Array [0] = "a"
Array [1] = "b"
Array [2] = "c: d"
what regular expression is used to achieve the desired result.
Many thanks
If the colon separator is separated by a space, you can use \ s to match the space:
string example = "a : b : \"c:d\""; string[] splits = Regex.Split(example, @"\s:\s");
This seems to work in RegexBuddy for me
(\w+)\s:\s(\w+)\s:\s"(\w+:\w+)"
input
mapped groups
abc: d
, . . \w, \s .. , !
\w
\s