fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern1 = @"^([0-9]{2,}?)[A-Z]?[0-9]?$";
  9. string pattern2 = @"^([0-9]{2})([0-9]+?)[A-Z]?[0-9]?$";
  10. string[] strings = { "171A1", "171A1", "171A", "171A0", "15211", "15211", "15211", "15210", "15190" };
  11.  
  12. foreach (String s in strings)
  13. {
  14. Console.WriteLine(Regex.Replace(s, pattern1, "$1"));
  15. Console.WriteLine(Regex.Replace(s, pattern2, "$1.$2"));
  16. }
  17. }
  18. }
Success #stdin #stdout 0.06s 30980KB
stdin
Standard input is empty
stdout
171
17.1
171
17.1
171
17.1
171
17.1
1521
15.21
1521
15.21
1521
15.21
1521
15.21
1519
15.19