Skip to content

Instantly share code, notes, and snippets.

@lol768

lol768/out.cs Secret

Last active May 21, 2017 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lol768/8dc865499c13c63b7be7423aec680c1c to your computer and use it in GitHub Desktop.
Save lol768/8dc865499c13c63b7be7423aec680c1c to your computer and use it in GitHub Desktop.
using System;
using System.Text.RegularExpressions;
namespace TestNamespace
{
internal class Program
{
public static string validaralfanum()
{
bool bandera = false;
Regex regex = new Regex(@"^[a-zA-Z0-9\s,]{4}$");
string unNum;
do
{
unNum = Console.ReadLine();
if (string.IsNullOrEmpty(unNum))
{
Console.WriteLine("Ingrese un ID");
}
else if (!regex.IsMatch(unNum))
{
Console.WriteLine("El ID debe ser alfanumérico");
}
else
{
bandera = true;
}
}
while (!bandera);
return unNum;
}
public static void Main(string[] args)
{
Console.WriteLine("Plese enter an alphanumeric 4-digit string");
String answer = validaralfanum();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment