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