Only letters:
Regex.IsMatch(input, @"^[a-zA-Z]+$");
Only letters and numbers:
Regex.IsMatch(input, @"^[a-zA-Z0-9]+$");
Only letters, numbers and underscore:
Regex.IsMatch(input, @"^[a-zA-Z0-9_]+$");
More Related Contents:
- Can I convert a C# string value to an escaped string literal?
- Get string between two strings in a string
- String output: format or concat in C#?
- Differences in string compare methods in C#
- Efficient way to remove ALL whitespace from String?
- Comparing two strings, ignoring case in C# [duplicate]
- How to replace multiple white spaces with one white space
- Convert JSON String to JSON Object c#
- Is there an alternative to string.Replace that is case-insensitive?
- How to include quotes in a string
- C# testing to see if a string is an integer?
- Checking if a string array contains a value, and if so, getting its position
- How to know the size of the string in bytes?
- IEnumerable to string [duplicate]
- Easiest way to parse a comma delimited string to some kind of object I can loop through to access the individual values?
- Convert string to decimal, keeping fractions
- How to do ToString for a possibly null object?
- Check if a string is a palindrome
- Instantiate a class from its textual name
- C# how convert large HEX string to binary
- .NET method to convert a string to sentence case
- Why does .ToString() on a null string cause a null error, when .ToString() works fine on a nullable int with null value?
- Converting String To Float in C#
- How to check if a String contains any letter from a to z? [duplicate]
- Detecting if a string is all CAPS
- Does C# have a String Tokenizer like Java’s?
- Convert String^ in c# to CString in c++/CLI
- convert string array to string
- How can I safely convert a byte array into a string and back? [duplicate]
- A fast hash function for string in C#