Compile regex in PHP

后端 未结 5 1607
离开以前
离开以前 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 03:58

    The Perl-Compatible Regular Expressions library may have already be optimized for your use case without providing a Regex class like other languages do:

    This extension maintains a global per-thread cache of compiled regular expressions (up to 4096).

    PCRE Introduction

    This is how the study modifier which Imran described can store the compiled expression between calls.

提交回复
热议问题