Solved

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

Posted on 2004-08-24
5
1,262 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
  • 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about problems I had with the new location API and permissions in Marshmallow
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now