[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1287
  • Last Modified:

How to check if a string contains strictly Letters and/or Numbers (ASP.NET)

Hello all,

This should be a simple question.  I would like to do a boolean test to ensure that a string contains letters or numbers or both.  Incase that is not clear, it may not contain any other character other than a letter or number.  Is there such a function in ASP.NET?


Please advise,

-TH
0
travishaberman
Asked:
travishaberman
  • 2
  • 2
1 Solution
 
Fahad MukhtarDistinguished EngineerCommented:
VB.Net or c#?
0
 
travishabermanAuthor Commented:
You know something.. I know this sounds stupid - But I don't even know.. I am fairly decent with C++ and this is my first time ever writing anything in a language like this..  I am working in the ASP "WEB MATRIX" .. Does that help?
0
 
ozoCommented:
If Not Regex.IsMatch( String, "[^A-Za-z0-9]" ) Then
   
End If
0
 
travishabermanAuthor Commented:
Thank you much...!
0
 
Fahad MukhtarDistinguished EngineerCommented:
its C# at the moment: you can convert it to vb.net

foreach (Char c in s.ToCharArray() )
      {
      if (!Char.IsLetter(c))
           break; // non letter charactar
      }
            
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now