using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"([M,F]\/\d{2}\/((\d{1}((\')|(\’))?(([0,2-9]|1[0-1]?)((\"")|(\'\')|(\”))?)?)|\d{1,3}cm|[1-2]m(\d{1,2}(cm)?)?)\s?\[\d{2,3}\s?(lbs|kg)\s?to\s?\d{2,3}\s?(lbs|kg)\]\s?\(((\d{1,2}\s?years?)|(([2-9]|1[0-1]?)\s?months?)|(\d{1,2}\s?years?(\;|\,)?\s?([0,2-9]|1[0-1]?)\s?months?)|(([2-9]|1[0-1]?)\s?weeks?))\)\s?(\s?\+\s?\(([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?([DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)(\;|\,))?\s?[DSBO]{1}:\s?(\d{2,3})\s?(lbs|kg)\))?.*)|(^\[Meta\].*)";
string input = @"
M/20/5'10"" [150lbs to 180lbs] (2 years; 6 months) + (B: 300lbs; S: 410lbs; D: 480lbs)
F/26/5'2"" [52kg to 59kg] (5 years)
M/35/6'3"" [203lbs to 175lbs] (7 months) - Additional comments here
M/20/5'10"" [150lbs to 180lbs] (2 years; 6 months) + (B: 300lbs; S: 410lbs; D: 480lbs) ";
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