正则表达式的一个简单匹配问题

来源:百度知道 编辑:UC知道 时间:2024/07/03 00:35:50
我想将
http://cc.net/new/html/2/4572/399.htm
这种类型的字符串转换成
page.php?html=2&bid=4572&list=399

请高手帮忙写一个,我自己写老是提示错误
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash,郁闷得紧,我调试了好多遍了

完整的测试程序如下:

<?php
$str='http://cc.net/new/html/2/4572/399.htm';
$str=preg_replace(
'|http://cc.net/new/html/(\d+)/(\d+)/(\d+).htm|',
'page.php?html=$1&bid=$2&list=$3',
$str);
echo $str;
?>

以上程序自PHP5下测试通过,在PHP4、PHP3应该没有问题。