Solved

How do you test a String for all alpha characters

Posted on 2003-10-23
4
395 Views
Last Modified: 2010-05-18
How do you test a String for all alpha characters, or all numeric characters returning a bool?
0
Comment
Question by:rayskelton
[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
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 9606184
 public static String allAlpha(String s) {
      StringBuffer sb = new StringBuffer(s);
      for(int i = 0;i < sb.length();i++) {
        if(Character.isAlphaChar(sb.charAt(i)) == false)
            return false;
      }
      return true;
  }

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9606194
isAlphaChar

should be

isLetter
0
 

Author Comment

by:rayskelton
ID: 9606520
Perfect, I changed the return to boolean.

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9608054
>>I changed the return to boolean.

D'oh, another error ;-)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse buid path vs tomcat lib path 10 49
ejb example issues 3 90
going to wrong jsp page 2 70
maven not picking latest jar instead picking old jar from .m2 12 75
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

752 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