using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<ChapterAuthors>[A-Z'a-z,\s]+?)(?: et al)?:(?<ChapterTitle>[A-Za-z,#\(\)\/0-9""’'&\sö]+)\.\s?In\s?(?<BookAuthors>[A-Za-z,\s]+?)(?: et al)?:(?<BookTitle>[A-Za-z,#\(\)0-9""’'&\s]+)\.\s?(?<Edition>\d+(?:rd|nd|st|th)\s(?:[eE]d|[eE]dition|))\.(?<Location>[-A-Za-z,.\s]+):(?<Publisher>[-A-Za-z,\(\)\/&\s]+)[\.]\s?(?<StartPage>\w?\d+\w?)-\s?(?<EndPage>\w?\d+\w?)[,\.;]\s?(?<Year>\d{4})";
string input = @"Johnson M: Amino acids and proteins. In Burtis CA et al: Tietz Fundamentals of Clinical Chemistry. 6th ed. St. Louis: Saunders. 286-310, 2008
Dufour DR: Liver disease. In Burtis CA et al: Tietz Fundamentals of Clinical Chemistry. 6th ed. St. Louis: Saunders. 675-95, 2008
Cunningham FG et al: Diseases and abnormalities of the placenta. In: Licht J, ed. Williams's obstetrics. 19th ed. Norwalk, Conn: Appleton & Lange. 748-59, 1993
Tille PM: Enterobacteriaceae. In Tille PM: Bailey & Scott’s Diagnostic Microbiology. 13th ed. St. Louis: Mosby. 307-28, 2013";
foreach (Match m in Regex.Matches(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