fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string test = "This string has 1000, 2000, 3000, 4000 numbers as 1 or 2 or 3";
  9. string pattern = @"\d+";
  10. // Match match = Regex.Match(test, pattern);
  11. // while(match.Success){
  12. // Console.WriteLine(match.Value);
  13. // match = match.NextMatch();
  14. // }
  15. test = "42 is lucky number";
  16. Console.WriteLine(Regex.IsMatch(test, pattern));
  17. test = "4245";
  18. Console.WriteLine(Regex.IsMatch(test, @"^\d$"));
  19. }
  20. }
Success #stdin #stdout 0.06s 29504KB
stdin
Standard input is empty
stdout
True
False