文字列(テキスト)から「悪い」単語を削除するようにコードを書き込もうとしています。
その後にコンマまたは特別な記号が含まれている場合、その単語は「悪い」です。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>