我正在尝试编写代码,以便从字符串(文本)中删除“坏”字。
如果单词后面有逗号或任何特殊符号,则该单词是“坏的”。a to z
如果仅包含(小写字母),则该词不是“坏” 。
所以,我想要达到的结果是:
<script>
String.prototype.azwords = function() {
return this.replace(/[^a-z]+/g, "0");
}
var res = "good Remove remove1 remove, ### rem0ve? RemoVE gooood remove.".azwords();//should be "good gooood"
//Remove has a capital letter
//remove1 has 1
//remove, has comma
//### has three #
//rem0ve? has 0 and ?
//RemoVE has R and V and E
//remove. has .
alert(res);//should alert "good gooood"
</script>