Results 1 to 5 of 5
  1. #1
    Hayzam is offline Member
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default deleting characters from a String

    if i have String S which contains a mix of numbers , spaces , lower case and higher case characters ...

    how can i delete the numbers and higher case characters , leaving spaces and lower case chars . ?!

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    Java Code:
    str = str.replaceAll("[A-Z]", "").replaceAll("[0-9]", "");
    dont worry newbie, we got you covered.

  3. #3
    Hayzam is offline Member
    Join Date
    May 2008
    Posts
    9
    Rep Power
    0

    Default

    thanks alot , but what about the special characters like ; : / { } ....etc

    how can i delete them ?

  4. #4
    Join Date
    Aug 2008
    Location
    Saint-Petersburg, Russia
    Posts
    66
    Rep Power
    0

    Default

    Java Code:
    str = str.replaceAll("[0-9A-Z;:/{}]", "");

  5. #5
    Join Date
    Aug 2008
    Location
    Saint-Petersburg, Russia
    Posts
    66
    Rep Power
    0

    Default

    See Pattern class documentation for regular expression syntax

Similar Threads

  1. how to get the characters one by one from a String?
    By Somitesh Chakraborty in forum New To Java
    Replies: 3
    Last Post: 08-20-2008, 08:56 PM
  2. Deleting from an object
    By vitaminz in forum New To Java
    Replies: 7
    Last Post: 08-10-2008, 03:56 AM
  3. Deleting Contractions
    By theonly in forum New To Java
    Replies: 3
    Last Post: 04-27-2008, 07:44 PM
  4. Replies: 3
    Last Post: 12-17-2007, 02:35 AM
  5. Getting all characters in a String
    By Alayna in forum New To Java
    Replies: 2
    Last Post: 05-20-2007, 11:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •