C#C
C#3y ago
Mek

✅ Learning Regex

string errorText = "Username Must Be Created Using The Letters A-Z, a-z, 0-9, or special characters !@#$%^&*";
string regex = // something here
string username = ColorCon.GetStringFromConsole(
  prompt: "Create A Username:",
  color: ConsoleColor.White,
  validator: x => x.IsMatch(regex),
  errorMessage: errorText);
I've never learned to create regex strings for validation, and I'm wanting to learn how to use/create them. I've used them before, but it was just a mere "<something_here> regex validation" on google, copy/paste and go.
  1. What is a regex string
  2. How do I write them to get the format that I'm wanting?
  3. For this specific purpose, the username should be able to be something like someUsername, some$Username, or SomEU123sername!$ Thanks
Was this page helpful?