Re: How to check for string as alpha or numeric??



I would look into the Regex class and regular expressions. You can use
Regex to check the string against any pattern you like, "all digits"
being one possible pattern, which would look like this:

if (Regex.IsMatch(myString, @"^\d+$")) ...

which will match a string containing one or more digits and nothing
else.

.



Relevant Pages

  • Re: Trouble with $key to HASH when Numeric
    ... the end of a string -- in other words, this pattern will always match ... and capture either 5 digits or nothing; 2) the pattern is anchored to ... modifier, which you do not). ...
    (comp.lang.perl)
  • Re: Entropy in crystalization: up or down?
    ... Strings of digits without context are without ... have short and long blips, as in a Morse Code-type pattern, and these ... any string of digits in pi will be found within any ... artifact behind such patterns. ...
    (talk.origins)
  • Re: Regex question
    ... if I have the following string: ... a pattern of: 2 digits, a slash, 2 more digits, another slass and 4 ... So if your regex ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: regular expressions help
    ... digits, then some text, empty, one alpha character, ... I have the following Regex pattern in my code ... then 1 or 2 digits) from a longer string as long as that pattern is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex question
    ... if I have the following string: ... a pattern of: 2 digits, a slash, 2 more digits, another slass and 4 ... So if your regex contains it will automatically create grouped values in your match object. ...
    (microsoft.public.dotnet.languages.csharp)