Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JavaScript字符串替换中负匹配正则表达式?_Javascript_Regex_Regex Negation - Fatal编程技术网

如何在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