[Plain Text] 纯文本查看 复制代码
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
[PHP] 纯文本查看 复制代码
<?php
$pattern = '/(https?|ftps?):\/\/(www)\.([^\.\/]+)\.(com|net|org|cn)(\/[\w-\.\/\?\%\&\=]*)?/i';
$subject = "欢迎阅读 http://www.groad.net/bbs/read.php?tid-7070.html 此篇帖子";
if (preg_match($pattern, $subject, $matches)) {
echo "$matches[0]"."<br>";
echo "$matches[1]"."<br>";
echo "$matches[2]"."<br>";
echo "$matches[3]"."<br>";
echo "$matches[4]"."<br>";
echo "$matches[5]"."<br>";
}
?>