Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Why Is My Regular Expression Still Returning False

$
0
0

Hi,

I have the following code and I enter input that isn't allowed but instead of getting a success from my regex match it is still returning false. Here's 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
}



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>