using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!-)((\d+(\.\d+)?))(\s*[xX]\s*\d+(\.\d+)?){1,2}\s*(mm|cm|mtrs|ft|yd)";
string input = @"120x200mm matches
12.2x200.3mtrs matches
2x21x21cm // needs to match
100\' X 130\'
4 acres
0.54
0.488 (90x223)/ GIS0.78
90x160
100x149.7x123
143.76 X 453.52
6.13 per tax bill
120x378 per tax roll";
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