Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing dot symbol from a string [duplicate]

Tags:

javascript

Possible Duplicate:
How to replace all points in a string in JavaScript

I am trying to remove '.'(dot) symbol from my string. and The code that Ive used is

checkedNew = checked.replace('.', ""); 

Bt when I try to alert the value of checkedNew, for example if the checkedNew has original value U.S. Marshal, the output that I get is US. Marshal, it will not remove the second dot in that string. How do remove all dot symbols?

like image 259
user1371896 Avatar asked May 14 '12 13:05

user1371896


People also ask

How do you remove the period from a string?

One of the easiest ways to remove punctuation from a string in Python is to use the str. translate() method.


Video Answer


1 Answers

Split the string on all the .'s and then join it again with empty spaces, like this:

checkedNew = checked.split('.').join(""); 
like image 109
Elliot Bonneville Avatar answered Oct 02 '22 15:10

Elliot Bonneville