如何在Javascript中用字符集拆分子字符串上的字符串?

时间:2016-04-27 01:15:57

标签: javascript string

是否有一种非常简单的方法可以在不使用Regexp的情况下使用字符集在子字符串上拆分字符串?

<select class="form-control bfh-countries" data-country="US"></select>

我很感激任何建议。

1 个答案:

答案 0 :(得分:1)

您可以使用.replace()传递您不希望在输出中显示的值。

var str = 'abcd..,,qqww..::ss ';
var newStr = str.replace(/[.,:]/g,''); // if you want to replace them with spaces, change '' to ' '
alert(newStr) // results in abcdqqwwss

https://jsfiddle.net/kdqtpcq9/

相关问题