Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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 - Fatal编程技术网

Javascript 快速一:什么';这个正则表达式怎么了?

Javascript 快速一:什么';这个正则表达式怎么了?,javascript,regex,Javascript,Regex,我有一段代码: _regex = /((?<!placeholder)\w+(?:\s*=\s*(?:"[^"]*"|'[^']*')))/; imgTag = imgTag.replaceAll(_regex, ' '); _regex=/(? 或此行: _regex = /((?<!placeholder)\w+(?:\s*=\s*(?:"[^"]*"|'[^']*')))/; imgTag = imgTag.replace( new RegExp( /(

我有一段代码:

_regex = /((?<!placeholder)\w+(?:\s*=\s*(?:"[^"]*"|'[^']*')))/;     
imgTag = imgTag.replaceAll(_regex, ' ');
_regex=/(?
或行:

_regex = /((?<!placeholder)\w+(?:\s*=\s*(?:"[^"]*"|'[^']*')))/;     
imgTag = imgTag.replace( new RegExp( /((?<!placeholder)\w+(?:\s*=\s*(?:"[^"]*"|'[^']*')))/, "gi" ), ' ');

imgTag=imgTag.replace(新的RegExp(/(?Javascript不支持lookbehinds)。您不能编写以下代码:

(?<!placeholder)
您还需要调整替换字符串,因为这会在您要替换的字符串开始之前匹配额外的字符


这也行不通:
var regex=newregexp(/…/,“gi”);


改为这样写:
var regex=/…/gi;

JavaScript不支持查找隐藏模式。(这是
(?
部分。)

您使用的
RegExp
的可能重复是完全错误的,但是是的,您的正则表达式也不正确:
SyntaxError
。JavaScript不知道lookbehinds
?。可能是。这是我第一次与正则表达式有更多的接触。我正在使用O'Reilly的正则表达式烹饪书来学习some的东西,但肯定还有很多关于这些家伙的东西需要了解。你会说关于那个正则表达式什么是“完全错误的”?谢谢关于查找提示!谢谢,这确实是我的问题!还有关于新的正则表达式(/…/)
code,这是因为我想要
gi
标志,或者有另一种方法可以用
replace
函数实现?再次感谢!@BeOliveira:如果你使用的是
RegExp
,你必须使用字符串。请看@FelixKling:再次感谢!我非常喜欢RegEx,但仍在试图获得一般的理解。我使用了ode>regexp=/((?!占位符)\w+(?:\s*=\s*(?:“[^”]*“[^']*”))/gi;
,但现在我知道了如何使用
regexp
做同样的事情。谢谢你的指点!
(?<!placeholder)
((?!placeholder).{11}|^.{0,10})