using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"editor\s*\{[^{}""]*
# Notice that I enabled the /x flag ----->
# That just allows me to add comments here to make it more readable
# Match from opening to closing double quote for the 'key'
""[^""]*""
# Then any whitespace between the 'key' and 'value'
\s+
# Match from opening to closing double quote for the 'value'
""[^""]*""";
string input = @"""entity""
{
""id"" ""5040044""
""classname"" ""weapon_defibrillator_spawn""
""angles"" ""0 0 0""
""body"" ""0""
""disableshadows"" ""0""
""skin"" ""0""
""solid"" ""6""
""spawnflags"" ""3""
""origin"" ""449.47 5797.25 2856""
editor
{
""color"" ""0 0 200""
""visgroupshown"" ""1""
""visgroupautoshown"" ""1""
""logicalpos"" ""[-13268 14500]""
}
editor
{
""color"" ""0 0 200""
""visgroupshown"" ""1""
""visgroupautoshown"" ""1""
""logicalpos"" ""[-13268 14500]""
""specialchars"" ""}""
}
editor
{
""child"" ""0 0 200""
""visgroupshown"" ""1""
""visgroupautoshown"" ""1""
""logicalpos"" ""[-13268 14500]""
subgroup
{
""child"" ""42 42 42""
}
}
}
";
RegexOptions options = RegexOptions.IgnorePatternWhitespace;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx