Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Regular_Expressions
  8. {
  9. public class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13. Print01ValidUsernames();
  14. }
  15.  
  16. private static void Print01ValidUsernames()
  17. {
  18.  
  19. var stringText = Console.ReadLine().Split(new string[] { ", "}, StringSplitOptions.RemoveEmptyEntries) ;
  20. var final = new List<string>();
  21. foreach (var item in stringText)
  22. {
  23. if (item.Count()>=3 &item.Count()<=16)
  24. {
  25. foreach (var kvp in item)
  26. {
  27. if ( char.IsLetter(kvp)|| kvp =='-' || kvp =='_' ||char.IsDigit(kvp))
  28. {
  29. final.Add(item);
  30. }
  31. else
  32. {
  33. final.Remove(item);
  34. break;
  35. }
  36. }
  37.  
  38. }
  39. }
  40. foreach (var item in final.Distinct())
  41. {
  42. Console.WriteLine(item);
  43. }
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement