我需要匹配###
和###
之間的內容,現在我的正則表達式我想出了「作品」,但是我也在開頭和結尾選擇了新行的內容,我的生活非常複雜。正則表達式在正向lookbehind和正向lookahead之間匹配多行
這是我的正則表達式:
(?<=\#\#\#)[\w\W]*?(?=\#\#\#)
我想我只能匹配的內容,如果沒有新的線路。
一些示例文本:
###
stackoverflow.com - penguin;stackoverflow;html;nospin
http://stackoverflow.com
Writing the perfect question
How to ask questions the smart way
Help vampires
How to ask a question
###
stackoverflow.com - pyramid;stackoverflow;bb;spin
http://stackoverflow.com
Writing the perfect question
How to ask questions the smart way
Help vampires
How to ask a question
###
stackoverflow;stackoverflow;wiki;nospin
http://stackoverflow.com
Writing the perfect question
How to ask questions the smart way
Help vampires
How to ask a question
###
stackoverflow;stackoverflow;bb;spin
http://stackoverflow.com
Writing the perfect question
How to ask questions the smart way
Help vampires
How to ask a question
###
只是從你的比賽中脫掉換行符,是什麼問題? –
我建議這不是正則表達式的好用,因爲它掩蓋了你想要做的事情。正則表達式對於單行文本非常好,但在處理文本塊時會變得非常複雜。你在用什麼語言?將自己讀入數組可能更好,然後當你點擊'###'處理你讀過的行時。 –
當我與它合作時,我在這件事上非常受限,一些名爲ZennoPoster的東西 - 基本上它的低劣的框架。 –