This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to replace comma (,) with a dot (.) using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to replace comma (,) with a dot (.) using java" Watch "How to replace comma (,) with a dot (.) using java" New topic
Author

How to replace comma (,) with a dot (.) using java

alpesh helwatkar
Ranch Hand

Joined: Apr 06, 2009
Posts: 30

Hi i'm doing


for replacing the comma with a dot but unable to do so... m i using the wrong regular expression?. please help
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 5048
    
  10

Regex looks to be ok, but you're discarding the return value.


luck, db
There are no new questions, but there may be new answers.
alpesh helwatkar
Ranch Hand

Joined: Apr 06, 2009
Posts: 30

so should i take it in a new variable? like
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4541
    
    8

Or just the same variable:
I don't think the second argument needs to be a regular expression, just a standard string (with a few exceptions, but I don't think a dot is one of them).
alpesh helwatkar
Ranch Hand

Joined: Apr 06, 2009
Posts: 30

hi.. yes.. i did used the same variable and it worked! thnx for the support!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20136
    
  30

Unless you need to use regular expressions, it's better to use replace: That way you don't need to worry about escaping any values.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to replace comma (,) with a dot (.) using java
 
It's not a secret anymore!