Advertisement
areyesram

Untitled

Apr 5th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace FilterOut
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Validate("valid_strig_123");
  11. Validate("I think not!");
  12. }
  13.  
  14. static void Validate(string s)
  15. {
  16. var re = new Regex(@"[^a-z0-9_]", RegexOptions.IgnoreCase);
  17. if (re.IsMatch(s))
  18. Console.WriteLine("Nope");
  19. else
  20. Console.WriteLine("OK");
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement