using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\+ *|- *)?((?!0+)\d*?|(?!0{2,})\d*?\.(?!0+)\d*?)('|"")$|^(\+ *|- *)? *(?!0+)\d+?' *-? *(\d+?|\d*?\.\d*?)""$|^((\+ *|- *)?((?!0+)|0 )\d*? *(?!0+)\d+?\/(?!0+)\d+?('|""))$";
string input = @" -
+
- x 20'-4""
+ 20'
- 20'
20'3""
20'-3""
20' - 40""
-20'-20""
20'00""
20.45""
20.45'
00.45'
00.45""
00""
00'
+20' - 0.45""
20' - .45""
.20'-4""
0.30'-4""
20'
20'P
20""
20""P
0.20'
.20'
a'
b""
- 20 1/2'
+ 20 22/128""
20 0/2""
20 00/12'
-1/2""
+ 1/2'
0/2""
00/22""
+ 01/2""
23 00/30'
23 12/03'
23 02/20""
0 2/3'
00 2/3'
- 11 2/3'
2 22'
2 22/03'
2 3/2
23 00/30
23 12/03
23 02/20
23/34""
23/23.4""
asf sf""
";
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