I'm trying to parse a file's contents using regex, but the patter I came up with doesn't seem to work.
The regex I am trying to use is
string regex = @"^(?<key>\w+?)\s*?:\s*?{(?<value>[\s\S]+?)}$";
and the text i am trying to parse it against is
string text = @"key:{value}
key:{valu{0}e}
key:{valu
{0}e}
key:{val-u{0}e}
key:{val__[!]
-u{0}{1}e}";
However, it returns 0 results
MatchCollection matches = Regex.Matches(text, regex, RegexOptions.Multiline);
I have tried testing this regex on RegExr, which worked as expected.
I am unsure why this doesn't work when trying it in C#.
MCVE:
string regex = @"^(?<key>\w+?)\s*?:\s*?{(?<value>[\s\S]+?)}$";
string text = @"key:{value}
key:{valu{0}e}
key:{valu
{0}e}
key:{val-u{0}e}
key:{val__[!]
-u{0}{1}e}";
MatchCollection matches = Regex.Matches(text, regex, RegexOptions.Multiline);
Console.WriteLine(matches.Count);