从字符串中删除点符号 [英] removing dot symbol from a string

查看:112
本文介绍了从字符串中删除点符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在JavaScript中替换字符串中的所有点

我试图从我的字符串中删除'。'(点)符号。我使用的代码是

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

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

当我尝试提醒checkedNew的值时,例如,如果checkedNew具有原始值US Marshal ,我得到的输出是美国。 Marshal,它不会删除该字符串中的第二个点。如何删除所有点符号?

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?

推荐答案

在所有上拆分字符串。然后再用空格连接它,如下所示:

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

checkedNew = checked.split('.').join("");

这篇关于从字符串中删除点符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆