Solved

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

Posted on 2004-08-24
5
1,281 Views
Last Modified: 2012-06-27
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
Comment
Question by:travishaberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Desp
ID: 11889661
VB.Net or c#?
0
 

Author Comment

by:travishaberman
ID: 11889680
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
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 11889686
If Not Regex.IsMatch( String, "[^A-Za-z0-9]" ) Then
   
End If
0
 

Author Comment

by:travishaberman
ID: 11889695
Thank you much...!
0
 
LVL 19

Expert Comment

by:Desp
ID: 11889734
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Make the most of your online learning experience.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question