Compile regex in PHP

后端 未结 5 1605
离开以前
离开以前 2020-12-13 03:25

Is there a way in PHP to compile a regular expression, so that it can then be compared to multiple strings without repeating the compilation process? Other major languages

5条回答
  •  佛祖请我去吃肉
    2020-12-13 04:19

    As another commenter has already said, PCRE regexes are already compiled without your having to specifically reference them as such, PCRE keeps an internal hash indexed by the original string you provided.

提交回复
热议问题