fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = @"65%POLYESTER 30%COTTON 5%WOOL";
  10. var list = new List<string>();
  11. var regex = new Regex("\\d*(?:\\.)?\\d+%?[^\\s]+");
  12. var matches = regex.Matches(s);
  13. foreach (Match item in matches)
  14. {
  15. list.Add(item.Value);
  16. Console.WriteLine(item.Value);
  17. }
  18. }
  19. }
Success #stdin #stdout 0.07s 34720KB
stdin
Standard input is empty
stdout
65%POLYESTER
30%COTTON
5%WOOL