using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\s*
(
(?<type>int(?:\s+long|\s+short)?|double(?:\s+long)?|
long(?:\s+int|\s+double)?|short(?:\s+int)?|float|char)
|
(?<error>\w+|\w+\s*\,)
)
\s+
(?:
(?:
(?:
(?<error>int|double|float|char|long|short|[^,;a-zA-Z_].+?|[^,;]+?(?:\s+\w+?)+)
|
(?<id>[a-zA-Z_][a-zA-Z_0-9]*)
)
(?:\s*\[\s*[1-9]\d*\s*\])*
)
\s*
(?:\,\s*|(?=\;))
)+
\s*\;\s*";
string input = @"int
abv, cde, doub1lel,ded, cto, int1;
float ng23423, _ga45,
astories;
int af , f;
int a, b, c;int short alt ;
long double fgd [ 1 ], [1] , wef ;
char _a[1], fi [
3
] [ 10] [ 4 ] ,g[1];int qw;";
RegexOptions options = RegexOptions.Multiline | 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