Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ValidUsernames
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- string[] usernames = Console.ReadLine().Split(", ",StringSplitOptions.RemoveEmptyEntries);
- StringBuilder sb = new StringBuilder();
- foreach (var name in usernames)
- {
- bool isValid = true;
- if (name.Length>=3 && name.Length <= 16)
- {
- foreach (var symbol in name)
- {
- if(!(char.IsLetter(symbol) || char.IsDigit(symbol) || symbol=='-' || symbol == '_'))
- {
- isValid = false;
- break;
- }
- }
- if (isValid == true)
- {
- sb.AppendLine(name);
- }
- }
- }
- Console.WriteLine(sb);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement