php preg_match()问题?
收藏:
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in C:\Apache2.2\htdocs\php\preg.php on line 2
应该是正则表达式没有加左右侧的斜线吧,比如
$result = preg_match(‘/^abc/’, ‘abcdef’, $matches)我猜测的话,你的正则不等式没有放在符号里面,一般应该这样’/…./’,你省略了里面的/就不对
如
<?php
$aa=”html/sell/2008/07/28/10.html”;
$xianshi = preg_replace(‘html\/(.+?)\/(.+?)\/(.+?)\/(.+?)\/(.+?)’,’info-$1-$2-$3-$4-$5′,$aa);
echo $xianshi;
?>改为:
<?php
$aa=”html/sell/2008/07/28/10.html”;
$xianshi = preg_replace(‘/html\/(.+?)\/(.+?)\/(.+?)\/(.+?)\/(.+?)/’,’info-$1-$2-$3-$4-$5′,$aa);
echo $xianshi;
?>