Regular Expression For Alphanumeric

Regular Expression For Alphanumeric

Alphanumeric pattern Its very simple using regular expression to find specified pattern of string.
Here we will see how to validate string against alphanumeric pattern.

Lets see the code.

protected void Button4_Click(object sender, EventArgs e)
string pattern = "^[A-Za-z0-9]";
string input = "This is string  containing special character ! ";
Regex re = new Regex(pattern);
Response.Write(string.Format(" {0} Is valid Alphanumeric string", input ));
Response.Write(string.Format(" {0} Is not valid Alphanumeric string", input ));

The input string contains “!” as a special character.
Pattern "^[A-Za-z0-9]" is used for validating string.

using System.Text.RegularExpressions; 

Above namespace is used for Regular expression pattern validation.

Instance of Regex constructor accepts the required pattern of expression.
IsMatch is instance method verifies whether string  contains pattern match or not.

You can also see how to get matched email string pattern by clicking on below link.


C# Regular Expression Get Text Between BracketsRegular expression for date pattern yyyy-mm-ddRegularExpression remove html tagsRegular expression for getting words from stringCheck Email AddressBulk EmailLinq Array Order-ByLearn Linq Step By StepLinq Distinct ListString was not recognised as a valid datetimeAn unhandled exception of type 'System.StackOverflowException' occurred in


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.