Why Is My Regular Expression Still Returning False

  • Thread starter Thread starter ShatterStar2012
  • Start date Start date
S

ShatterStar2012

Guest
Hi,

I have the following code and I enter input that isnt allowed but instead of getting a success from my regex match it is still returning false. Heres my code

Sample input "^&*()><"

string usernameVal = textBoxUsername.Text.Trim();
string regexp = @"(^A-Za-z0-9)";

Regex regex = new Regex(regexp);
Match usernameMatch = regex.Match(usernameVal);

if (usernameVal.Length > 0 && usernameMatch.Success == false)
{
// code
}

Continue reading...
 
Back
Top