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
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.