Hi internals, PCRE has support for "callouts", which allow calling a custom function at specified points during pattern matching. This functionality is documented at https://www.pcre.org/current/doc/html/pcre2callout.html.
I've implemented a prototype for exposing this functionality in PHP at https://github.com/php/php-src/pull/3970, which also has more information on the API and usage. One use case for this functionality is in junction with auto-callouts, which allows tracing the execution of regular expressions, exactly as PCRE performs it. This may be useful for debugging and performance optimization. I've included an example for that in the PR. Regards, Nikita