Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

820 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