-
-
Save lol768/8dc865499c13c63b7be7423aec680c1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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