有人可以帮我吗? 模式是preg_replace():编译失败
/\[url=?\]([a-z0-9:\.\\\/-\s]*?)\[\/url\]/isS
错误:
preg_replace(): Compilation failed: invalid range in character class at offset 26
有人可以帮我吗? 模式是preg_replace():编译失败
/\[url=?\]([a-z0-9:\.\\\/-\s]*?)\[\/url\]/isS
错误:
preg_replace(): Compilation failed: invalid range in character class at offset 26
这应该在PHP中工作(PCRE):
/\[url=?\]([a-z0-9:\.\\\/\-\s]*?)\[\/url\]/is
首先在你的角色类声明中跳过-
[]
否则你会得到一个错误的范围错误。
第二个/S
修饰符可能不是您的模式的好主意。阅读:
When a pattern is going to be used several times, it is worth spending more time analyzing it in order to speed up the time taken for matching. If this modifier is set, then this extra analysis is performed. At present, studying a pattern is useful only for non-anchored patterns that do not have a single fixed starting character.
要测试你的正则表达式regex101.com是相当不错的。
哪个是人物26? – rghome