程式
<?
$str = "This is the [*worst*] day [*of*] my life.";
preg_match_all("[*([^*]+)*]", $str, $out, PREG_PATTERN_ORDER);
echo "str = '$str' <br>";
echo "<pre>" . print_r($out, true) . "</pre>";
?>
錯誤訊息
Warning: preg_match_all() [function.preg-match-all]: Delimiter must not be alphanumeric or backslash in D:\TMS\www_test\index.php on line 3
原因
ereg 系列的function pattern 參數前後不需要加上 /
而 preg 系列的 function 卻要加
解法
所以第三行改為
preg_match_all("/[*([^*]+)*]/", $str, $out, PREG_PATTERN_ORDER);
就可以了
請先 登入 以發表留言。