Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
現在、数値以外の文字に一致する正規表現があります。
var.replace(/[^0-9a-zA-Z ]/,'');
数字だけでなくスペースも保持する必要がありますが、これを変更するのは困難です。
何か助けはありますか?
これは、数字でもスペースでもないすべてのものに一致する正規表現です..
[^0-9\s]
説明ちょっと正規表現エンジン:
1-すべてのものに一致します。
2- ^--> そうではない
^
3- 0-9--> 数字
0-9
4- \s--> とスペース
\s