如何在JavaScript字符串替换中负匹配正则表达式?
我试图将除数字以外的所有字符替换为空白,但这不起作用:如何在JavaScript字符串替换中负匹配正则表达式?,javascript,regex,regex-negation,Javascript,Regex,Regex Negation,我试图将除数字以外的所有字符替换为空白,但这不起作用: s.替换(/(?!\d)/g',) 谢谢 使用负字符类: s.replace(/[^0-9]+//g',) 或s.replace(/[^\d]+//g',) 或s.replace(/\D+/g',)/[^\D]/g
s.替换(/(?!\d)/g',)
谢谢 使用负字符类:
s.replace(/[^0-9]+//g',)
或s.replace(/[^\d]+//g',)
或s.replace(/\D+/g',)
/[^\D]/g