How to check if a string contains alphabets?

I can check if a string contains an integer but unable to do for a alphabet?

Hey @ishankakar


Remember to use Regex class, you have to use namespace System.Text.RegularExpressions in your import

or one more way

bool result = hello.Any(function(x) NOT char.IsLetter(x))

For above you have to import System.LINQ namespaces in your project.



Thank you for your help

For alphabets it’s working fine but I want to check for numbers as well

Hey @Bachali

If you want to just check a string is only alphabets and Numbers then you can use below Regex Patter,

Int Count = Regex.Matches(str,“[1]+$”).Count

By Linq -

Bool IsAlphnumornot="Your String".All(function(c) Char.IsLetterOrDigit(c))

or if you want to check that any character is Alphanumeric or Digits/Number as well then can use below Linq

Bool IsAlphnumornot="Your String".Any(function(c) Char.IsLetterOrDigit(c))


  1. a-zA-Z0-9 ↩︎

1 Like

Thanks @aksh1yadav It’s working :blush:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.