Arturito.net

Come to The Dark Side, We Have Cookies!

Visual Studio C# Regular Expressions Examples

without comments

Numeric values:


public bool isNumeric(string str) {
Regex pattern = new Regex("[^0-9]");
return !pattern.IsMatch(str);
}

Alfa values:


private bool IsAlpha(string str) {
Regex pattern = new Regex("[^a-zA-Z]");
return !pattern.IsMatch(str);
}

Alfa numeric values:

private bool isAlfaNumeric(string str) {
Regex pattern = new Regex("[^a-zA-Z0-9]");
return !pattern.IsMatch(str);
}

Written by guru

March 26th, 2010 at 4:53 pm

Posted in C++