Recently I needed to validate a string input by a user to ensure it was in a specific format. One of the requirements was that the first character of the string had to start with a alpha character (A-Z). Here is how you can accomplish this:
string alphatag = tag.Substring(0,1);
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(“[a-zA-Z]”);
bool isalpha = regex.IsMatch(alphatag);
Utilizing the RegularExpressions class is a very useful tool in comparing values against specific patterns.



