作者knives ()
看板PHP
標題[請益] 這個正規語法怎麼一直都會有error
時間Fri May 28 09:05:08 2010
我的字串是<a href="space.php?uid=77>xxx</a>
可是裡面的連結可能是這樣 space.php?tid=99&uid=77
所以我打算用 正規表示法來取得裡面uid的值
我的pattern是這樣
$re = '/^<a*href=*space.php?*uid=*/i';
然後我用preg_match來做
if(preg_match($re, $str, $matches))
{
print_r($matches);
}
但是一直會有警告
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to
repeat at offset 21
請問到底要怎麼寫才對阿
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.39.194
推 EragonJ:太多錯誤了.. 主要出問題是因為你?*寫在一起沒有跳脫 05/28 09:25
→ EragonJ:但是其他部分的RE幾乎都是錯的,你要不要再研究一下RE 05/28 09:26
→ EragonJ:還有就是,你print_r的地方也寫錯變數名了 05/28 09:27
→ knives:因為我是拿javascript的拿過來用的 05/28 10:04
※ 編輯: knives 來自: 122.117.39.194 (05/28 10:06)
推 JYHuang:js跟php的pattern用法有點不同 05/28 10:48