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.
我想将以下字符列入黑名单:
' ( = < >
所以每个字符都是允许的,但不是上面列出的 5 个。
如何用正则表达式替换它们?
myString.replace(regexString, '');
myString.replace(/['(=<>]/g, '');
尝试:
测试:
console.log("Hello' = (< >World!".replace(/['(=<>]/g, ''));
结果:
Hello World!
更多信息: