This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Strip Characters out of String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Strip Characters out of String" Watch "Strip Characters out of String" New topic
Author

Strip Characters out of String

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
I need help to strip all characters out of a string except numbers and commas's.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

What have you tried?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
fred rosenberger wrote:What have you tried?


I have this but it will strip out even the commas

Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

You've told it not to strip only digits. Would adding comma do the job:


The quieter you are, the more you are able to hear.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
Kemal Sokolovic wrote:You've told it not to strip only digits. Would adding comma do the job:


That worked great. Thanks
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strip Characters out of String
 
Similar Threads
  ...
Is this a valid way to remove control characters: "{cntrl}"
Formatting problem
Removing ^M Characters in Java
Efficient Way To Remove Non Alphanumerics From A String