在速度我有:
#set( $text = "#parse('file url')" )
我想要的是只提取div中名为“paragrafo-html”的文本。
文件内容和正则表达式在这里:
https://regex101.com/r/wr8H04/1
我写道:
$text.replaceAll('(?:.|\\n)*?<div class="paragrafo-html" style="">((?:.|\\n)*?)</div>(?:.|\\n)*', '$1')
但正如我所说的正则表达集团那样,它不起作用。
也:
$text.matches('(?:.|\n)*?<div class="paragrafo-html" style="">(?:.|\n)*?</div>(?:.|\n)*')
给我错误。
你能否告诉我在replaceAll中我做错了什么?
Wiktor Stribizew最后评论有效!所以:
$text.replaceAll('(?s).*?<div\s+class="paragrafo-html"\s+style="">(.*?)</div>.*', '$1')
谢谢!