using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"((RESERVADAS|[A-Z]+)[(][)][ ]*[\t]*[\r\n|\n]*([{][\r\n|\n]*([\t]*[ ]*[0-9]+[ ]*[=][ ]*(['][A-Z]+['])[\r\n|\n]*)+[\r\n|\n]*[}][\r\n|\n]*)*)";
string input = @"RESERVADAS()
{
18 = 'PROGRAM'
19 = 'INCLUDE'
20 = 'CONST'
21 = 'TYPE'
22 = 'VAR'
23 = 'RECORD'
24 = 'ARRAY'
25 = 'OF'
26 = 'PROCEDURE'
27 = 'FUNCTION'
28 = 'IF'
29 = 'THEN'
30 = 'ELSE'
31 = 'FOR'
32 = 'TO'
33 = 'WHILE'
34 = 'DO'
35 = 'EXIT'
36 = 'END'
37 = 'CASE'
38 = 'BREAK'
39 = 'DOWNTO'
}
COSO()
{
19='A'
}
";
RegexOptions options = RegexOptions.Multiline;
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