using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<entry>@(\w+)\{(\w+),(?<kvp>\W*([a-zA-Z]+) = \{(.+)\},)(?&kvp)*(\W*([a-zA-Z]+) = \{(.+)\})\W*\},?\s*)(?&entry)*";
string input = @"@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
},
@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
},
@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
}";
Match m = Regex.Match(input, pattern);
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