how-to-replace-all-occurrences-of-a-string-in-javascript

QuestionsCategory: IT & Communicationhow-to-replace-all-occurrences-of-a-string-in-javascript
priya sharma asked 7 months ago

I am trying to Replace 1,222,888,889.00  to 122288889.00 means replace all \”,\”  . I am using ReplaceAll but its showing No function exist. If i use Replace than it replacing only one \”,\” . Can anyone give me solution to remove all \”,\” ?

0

0

blog here replied 1 month ago

I simply want to say I am new to blogging and definitely enjoyed your web blog. Most likely I’m planning to bookmark your site . You certainly come with great stories. With thanks for sharing with us your blog site.

1 Answers
Kamal Kumar Rajak answered 7 months ago

you can use replace(/,/g,”).
var value=1,222,888,889.00
value1=value.replace(/,/g,”);
 
Output will be 122288889.00.

0

0

kamal Kumar Rajak replied 7 months ago

You can Use  regular expression or for loop with Replace also.
like-
for(i; i < value.length; i++) {
value=value.replace(',','');
}

Your Answer

by