作者yshihyu (yshihyu)
看板Python
標題[問題] regEXP
時間Sun Jul 27 01:08:23 2014
https://gist.github.com/anonymous/1de1969450a5537df2b2
我想濾出<table> 之間內容 </table>
我下面這樣regular expression 為什麼無法濾出?
\<table.*\<\/table
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.104.88.82
※ 文章網址: http://www.ptt.cc/bbs/Python/M.1406394508.A.221.html
→ mars90226:\<table.*?\<\/table 07/27 01:14
→ mars90226:sorry,沒注意到換行,<table[\s\S]*?<\/table> 07/27 01:25
→ mars90226:<應該不需要escape 07/27 01:25
→ yshihyu:需要用到[\s\S]*? 的 ?, [\s\S]* 好像就可以是嗎? 07/27 03:56
→ mars90226:如果你有很多table就會出錯 07/27 11:05
→ s860134: 那個?是懶惰匹配 會選擇最近的</table> 而非最後的 08/20 02:08