我想在PHP中使用Perl正则表达式

mas*_*asa 5 php perl

我想在PHP中使用perl reqexp.

例如,

Perl的:

$url =~ qr{https?://([^\/\?&:#]+\.)?example.com};
Run Code Online (Sandbox Code Playgroud)

PHP:

preg_match("/https?:\/\/([^\/\?&:#]+\.)?example\.com/", $url);
Run Code Online (Sandbox Code Playgroud)

小智 7

你是在自问自答?preg_match能够处理几乎所有的Perl正则表达式语法.("p"代表"Perl".)

preg_match在其文档中了解有关PHP的更多信息.