Taking out non-letters


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Taking out non-letters

  1. #1
    Join Date
    May 2005
    Posts
    7

    Taking out non-letters

    I'm am currently making a Palindrome program that checks to see if the entered string is a palindrome and if it is not checks if it is a almost-palindrome. An almost-palindrome is defined(by the book) is a palindrome once you remove all punctuation characters and such. I am having trouble doing this using a normal string and/or StringBuffer. This is what I am trying:

    Code:
    for(int c=0;c<sb.length();c++)
    		{
    			if((sb.charAt(c)<'a' || sb.charAt(c)>'z')&&(sb.charAt(c)<'A' || sb.charAt(c)>'Z'));
    			{
    				sb.deleteCharAt(c);
    			}
    		}
    Any suggestions would be appreciated.

  2. #2
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    Meditate on Character.isLetter().

  3. #3
    Join Date
    May 2005
    Posts
    7
    Wow, I feel stupid...I accidently put a semi-colon after my if statement

    Thanks for the help, Ray.
    Last edited by nrz; 05-25-2005 at 05:00 PM.

  4. #4
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    Wow, I feel stupid not seeing that but I'll lay it on the late hour reply. Still isLetter() is probably the best way to test.

  5. #5
    Join Date
    May 2005
    Posts
    7
    Yep, it's all working correctly now. That makes two of us that should have caught the mistake .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center