fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. // your code goes here
  9. string[] test = { "1.23", "123.45", "111", "12", "1", "0", "0.01", "0.0001", "0.00011", "0.000098", "1.000001", "-1.23", "-1", "-11", "-0.0000001" };
  10. foreach (var item in test)
  11. {
  12. var r = Regex.IsMatch(item, @"^(?!0\.0000)(?!^0$)\d+(\.\d+){0,1}");
  13. Console.WriteLine(item + ": " + r);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.1s 24712KB
stdin
Standard input is empty
stdout
1.23: True
123.45: True
111: True
12: True
1: True
0: False
0.01: True
0.0001: True
0.00011: True
0.000098: False
1.000001: True
-1.23: False
-1: False
-11: False
-0.0000001: False