Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
Php preg_匹配所有标记,除非标记具有类_Php_Regex - Fatal编程技术网

Php preg_匹配所有标记,除非标记具有类

Php preg_匹配所有标记,除非标记具有类,php,regex,Php,Regex,我有一个正则表达式,它可以替换文本中的短代码 [test_code] <textarea class="ignoreShortCodes">[test_code]</textarea> 请注意,短代码可以包含如下参数: [test_code name="test"] 谁能帮我解决这个问题?您可以使用消极前瞻: /^(?!.*ignoreShortCodes).*\\[([a-zA-Z0-9_-]+)\\s?(?:[^\\]]*)\\]/im 它将匹配不包含类的所有

我有一个正则表达式,它可以替换文本中的短代码

[test_code]

<textarea class="ignoreShortCodes">[test_code]</textarea>
请注意,短代码可以包含如下参数:

[test_code name="test"]

谁能帮我解决这个问题?

您可以使用消极前瞻:

/^(?!.*ignoreShortCodes).*\\[([a-zA-Z0-9_-]+)\\s?(?:[^\\]]*)\\]/im

它将匹配不包含类的所有对齐
忽略短代码

,谢谢您的回答!
/^(?!.*ignoreShortCodes).*\\[([a-zA-Z0-9_-]+)\\s?(?:[^\\]]*)\\]/im