有人可以幫我嗎? 模式是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