using System.Text.RegularExpressions;
public static void Main()
var regexPattern = @"(?:^0?[1-5](?:\.[0-9])?\+?)(?:\s?\-\s?[1-6])?\s?\-?\s?months?\s?(?:contract(?:ed)?)?\s?(?:plus)?|^0?6(?:\.0)?\s?\-?\s?months?\s(?!plus|\+)|^0?6(?:\.0)?\s?\-?\s?months?$";
var testStrings = new string[] {
"6 months plus contract",
var regex = new Regex(regexPattern, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled);
Console.WriteLine($"Does regexPattern match...\n");
foreach (var s in testStrings) {
var isRegexMatch = regex.IsMatch(s);
Console.WriteLine($"'{s}' {string.Join("", System.Linq.Enumerable.Repeat('.', Math.Max(50, s.Length)-s.Length))} {isRegexMatch.ToString().ToUpper()}");