[請益] preg_match_all中的! !is是什麼?

看板PHP作者 (真理斯金)時間16年前 (2009/08/04 12:30), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
※ [本文轉錄自 RegExp 看板] 作者: Geniusking (真理斯金) 看板: RegExp 標題: [問題] preg_match_all中的! !is是什麼? 時間: Tue Aug 4 10:13:43 2009 我寫了一個要抓option value中的字串的regexp 是用要php的preg_match_all抓 <option value="IamTarget">IamTarget(目標)</option> <option value="IamTarget2">IamTarget2(目標2)</option> 我用的RegExp是(忘了是參考到版上那一篇的) "!&lt;option value=.*?&gt;(.*?)(\(.*?\))?&lt;/option&gt;!is"; 問1:那個!與!is是什麼意思啊? 出來的結果是可以成功抓到我要的字串如下: 問2:有沒有其他建議的php Regexp寫法? Array ( [0] => Array ( [0] => <option value='IamTarget'>IamTarget(目標)</option> [1] => <option value='IamTarget2'>IamTarget2(目標2)</option> ) [1] => Array ( [0] => IamTarget [1] => IamTarget2 ) [2] => Array ( [0] => (目標) [1] => (目標2) ) ) 感謝各位大大! -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.83.216.112

08/04 10:14,
補充:我的html有先htmlspecialchars過
08/04 10:14
-- ╭──╮╭──╮┌╭─╮ ○ ┌┐┌┐╭──╮┌┐┌┐ ○ ┌╭─╮╭──┐ │╭─┘│╭╮││╭╮│ ┌┐ │││││╭─╯│╰╭╯ ┌┐ │╭╮││╭╮│ │┌┐││┌─╯││││ ││ │╰┘│╰─╮╮│╭╮╮ ││ ││││╰─┐│ ╰──╯╰──╯└┘└┘ └┘ ╰─└┘╰──╯└┘└┘ └┘ └┘└┘╰──╯ http://www.wretch.cc/blog/Geniusking -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.83.216.112

08/04 13:42, , 1F
跟/pattern/一樣,只是把/換成!,區別表達示、修飾子
08/04 13:42, 1F

08/04 14:01, , 2F
喔喔,謝謝~
08/04 14:01, 2F
文章代碼(AID): #1ATxbs3l (PHP)
文章代碼(AID): #1ATxbs3l (PHP)