fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] strings = {"msl_0123456789_otherstuff.csv", "msl_test.xml","anythingShort.w1", "123456testxxxxxxxx"};
  9. string pattern = @"^(?:msl_)?(\S{1,10})\S*\.[^\W_]{2,}$";
  10. foreach (String s in strings) {
  11. Match match = Regex.Match(s, pattern);
  12. if (match.Success)
  13. {
  14. Console.WriteLine(match.Groups[1]);
  15. }
  16. }
  17. }
  18. }
Success #stdin #stdout 0.06s 21276KB
stdin
Standard input is empty
stdout
0123456789
test
anythingSh