fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var packageSize = "4/8.75LB";
  11. //var packageSize = "LB"; // => 'LB' did not match the regex.
  12. var result = Regex.Split(packageSize, @"(\d)(?=\D*$)");
  13. if (result.GetLength(0) != 1) { // We have found a match
  14. foreach (var s in result)
  15. Console.WriteLine(s);
  16. }
  17. else
  18. {
  19. Console.WriteLine($"'{packageSize}' did not match the regex.");
  20. }
  21. }
  22. }
Success #stdin #stdout 0.09s 27268KB
stdin
Standard input is empty
stdout
4/8.7
5
LB