次のコードがあります。
ttt = 'hello---,,..there';
tt2 = strip(ttt);
alert(tt2);
function strip(str){
return str.replace(/[^a-zA-Z0-9 ,.-_]/g, '');
}
アラートが与えるhello,,..there
hello---,,..there
ハイフンを含むすべての文字が置換関数の例外として指定されているため、それが返されることを期待しています。
私は何を間違っていますか?
ありがとう。