preg_replace.php
<?php
$content="[page]第一页[/page][page]第二页[/page][Page]第三页[/pagE][page]第四页[/page]";
echo $content;
echo "<br/>";
#不区分大小写非贪婪匹配
#$content = preg_replace("/\[page\](.*)\[\/page\]/iU", "$1<br>", $content,3);
$content = preg_replace("/\[page\](.*?)\[\/page\]/i", "$1<br>", $content,3);
print_r($content);
echo "<br/>";
$pages="<br><a href=preg.php?page=1>page1</a><br><a href=preg.php?page=2>page2</a><br/><a href=index.php?page=3>page3</a>";
$pages=preg_replace("/(\w*)\.php\?page=(\d*)/i","$1_$2.html",$pages);
echo $pages;
?>
preg_match.php
<?php
$content="[page]page1[/page][page]page2[/page][page]page3[/page]";
echo $content."<br/>";
$content=preg_match_all("/\[page\](.*)\[\/page\]/U", $content, $m, PREG_PATTERN_ORDER);
print_r($content);
echo "<br/>";
print_r($m);
echo "<br/>";
$url="asdf/234234234_2.html";
preg_match('/([0-9]{0,})(\w*).html/i',$url,$matches);
print_r($url);
print_r($matches);
?>