过滤字符串中的分号 博客分类: AJax prototypeHTML
程序员文章站
2024-03-01 15:52:04
...
<html>
<head>
<script>
function kkbear(){
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
var kk =document.getElementById("kkbear").value;
var bear = kk.replaceAll('([;])+', ';');
alert(bear);
}
</script>
</head>
<body>
<input id="kkbear" name="kkbear" type="text"/>
<a href="#" onclick="kkbear();">kkbear</a>
</body>
</html>