Hướng dẫn javascript string remove dots
Remove all dots from a String #To remove all dots from a string: Show
We passed the following parameters to the String.replaceAll method:
We used an empty string for the replacement because we want to remove all dots from the string. The Alternatively, you can use the Remove all dots from a String using String.replace() #Use the
We passed the following parameters to the String.replace method:
The forward slashes
We prefixed the dot with a backslash to escape it. The dot We used the By replacing all dots with an empty string, we remove all dots from the string. The Which approach you pick is a matter of personal preference. I'd go with the Further Reading #
I am trying to remove '.'(dot) symbol from my string. and The code that Ive used is
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?
asked May 14, 2012 at 13:38
user1371896user1371896 2,0847 gold badges23 silver badges32 bronze badges 0 Split the string on all the
answered May 14, 2012 at 13:39
Elliot BonnevilleElliot Bonneville 49.9k23 gold badges93 silver badges123 bronze badges 6 You need to perform a global replacement as, by default,
answered May 14, 2012 at 13:40
QuentinQuentin 873k121 gold badges1170 silver badges1285 bronze badges replace will only replace the first occurance. To get around this, use a regex with the global option turned on:
answered May 14, 2012 at 13:41
Not the answer you're looking for? Browse other questions tagged javascript or ask your own question. |