fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Example
  5. {
  6. public static void Main()
  7. {
  8. string[] strings = {
  9. "ABC123",
  10. "ABC245",
  11. "ABC435",
  12. "ABC Oh say can You see"
  13. };
  14. string pattern = "ABC(?!123)";
  15. foreach (string str in strings)
  16. {
  17. Console.WriteLine(
  18. "\"{0}\" {1} match.",
  19. str, Regex.IsMatch(str, pattern) ? "does" : "does not"
  20. );
  21. }
  22. }
  23. }
Success #stdin #stdout 0.06s 34816KB
stdin
Standard input is empty
stdout
"ABC123" does not match.
"ABC245" does match.
"ABC435" does match.
"ABC Oh say can You see" does match.