我試圖編寫一個快速的正則表達式,但是當我測試它時,PHP (preg_replace_callback) 將有大量的步驟來獲得結果,我認為這不是一個好的性能 - 必須更快。我的正則表達式代碼:\{if\s{1}(.+?)\}\n(((?R)|.*?)+)\{\/if\}應該解析的代碼(遞歸):{if $name == 'Tree'} Hey, this is a Tree!{/if}{if $name == 'Example'} {if $number == '1'} Hey, this is an Example with the number 1 {/if}{/if}您可以在此處測試 regex101 上的示例。有沒有辦法加快我的正則表達式或者我必須接受那個速度?
可以加速 PHP 正則表達式
慕運維8079593
2023-05-12 14:33:17