• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
alpesh helwatkar
Ranch Hand
Posts: 30
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regex looks to be ok, but you're discarding the return value.
 
alpesh helwatkar
Ranch Hand
Posts: 30
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so should i take it in a new variable? like
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.. yes.. i did used the same variable and it worked! thnx for the support!
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic