Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use replace() to remove all commas from string 1

Status
Not open for further replies.

brownfox

Programmer
Jan 5, 2003
173
GB
How do I use replace() to remove all commas from string.
Code:
var my_string = "This is a string, it has a comma";
my_string = my_string.replace(",","");
?
T.I.A
 
Code:
var my_string = "This is a string, it has a comma";
my_string = my_string.replace(/,/g,"");


"It is the mark of an educated mind to be able to entertain a thought without accepting it." - Aristotle
 
Doesn't work, try it yourself. Error: This object doesn't support this property or method!
 
My apologies it did work, I'm using an array not a string, that's why there were commas. Thanks for the tip. Star awarded!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top