Meaningless Drivel is fun!
The moose likes Java in General and the fly likes need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "need help" Watch "need help" New topic

need help

Anil Kumar Saha
Ranch Hand

Joined: Apr 07, 2004
Posts: 111

I want to delete all the comma(,) and dot(.) from a string. That is if the input is "1,236,4as4.00" I want the output to be "12364as400". Any help will be highly appreciated.


Anil Kumar Saha
SCJP 1.4
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Something like String.replaceAll("[,\\.]\+", "") should do the trick.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14991

You can use the method String.replaceAll() for this. Note that the argument to the method is a regular expression.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Anil Kumar Saha
Ranch Hand

Joined: Apr 07, 2004
Posts: 111
Ulf Dittmer/Jesper Young,

Thanks a lot for your quick help.It is working.
I need to brush up on regular expressions.
I agree. Here's the link:
subject: need help
It's not a secret anymore!