I'd like to use Perl regular expression in PHP

perl, php

Solution

You answered your own question? `preg_match` is able to process virtually all of Perl regex syntax. (The "p" is for "Perl".)

Learn more about PHP `preg_match` in its documentation.

Problem

I wanto use perl reqexp in PHP. For example, Perl: ``` $url =~ qr{https?://([^\/\?&:#]+\.)?example.com}; ``` PHP: ``` preg_match("/https?:\/\/([^\/\?&:#]+\.)?example\.com/", $url); ```

Original source