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. "ABC"
  14. };
  15. string pattern = "ABC(?!123).";
  16. foreach (string str in strings)
  17. {
  18. Console.WriteLine(
  19. "\"{0}\" {1} match.",
  20. str, Regex.IsMatch(str, pattern) ? "does" : "does not"
  21. );
  22. }
  23. }
  24. }
Success #stdin #stdout 0.07s 34096KB
stdin
Standard input is empty
stdout
"ABC123" does not match.
"ABC245" does match.
"ABC435" does match.
"ABC Oh say can You see" does match.
"ABC" does not match.