Reputation: 11602
I have a string variable in C# and I want to check this string contains letters or not.
I used following regular expression for evaluate this condition, but I returned false in the if
statement I used.
I dont know why?
My C# Code:
string cellValue ="Row Merging Done here";
if (Regex.IsMatch(cellValue, @"^[a-zA-Z]+$"))
{
messageBox.show("Message found");
}
How to evalute this regular expression?
Upvotes: 1
Views: 8686
Reputation: 56716
Do you need to check whether the string contains at least one word? If so, you don't need symbols for beginning and end:
if (Regex.IsMatch(cellValue, @"[a-zA-Z]+"))
Upvotes: 3