using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?!-0?(\.0+)?$)-?(0|[1-9]{1,4}\d*)?(\.\d+)?(?<=\d)?()$";
string input = @"3
999
-3
0
0.0
1.0
0.1
.01
-0.0000000000000000000000000000000001
2e3
-2e3
2e-3
-2e-3
1.0e0
0.1e1
.01e-1
-9.1e3
-9.1e-3
9E5
0e-11
0xff
0XFF
0x0
0xfe3
-0
-0.0
-0.0000000000000000000000000000000000
-.0
-.0000000000000000000000000000000000
1xff
0x
0x0fg3
0xf4.
.0xf
0xfe-3
-0xff
0.0xff
0xff.1
e89
.e3
001
-00.2
3.
a
-1
--1
-.1
2..3
2-
2...3
2.4.3
5-6-7
.-1";
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