将div块与特定类“report-content”匹配
Regex using: /<div\\sclass="\report-content\">(.*?)<\/div>/
<div class="content"></div>
<div class="report-content">
Are you falling sick without any apparent illness?
Your job could be the reason behind it. Check the list
of jobs that could jeopardize your health and send you to the doctor.
</div>
<div class="report-content">
Are you falling sick without any apparent illness?
Your job could be the reason behind it. Check the list
of jobs that could jeopardize your health and send you to the doctor.
</div>
答案 0 :(得分:0)
这可行,试试吧:
/<div class=\"report-content\">(.*?)<\/div>/
答案 1 :(得分:0)
您的代码可以正常进行微调。此外,您应该包含s
修饰符以匹配换行符,如下所示:
/<div\ class=\"report-content\">(.*?)<\/div>/s
匹配
Are you falling sick without any apparent illness?
Your job could be the reason behind it. Check the list
of jobs that could jeopardize your health and send you to the doctor.
这是一个有效的演示:
答案 2 :(得分:0)
首先,您将\"
与类属性旁边的"\
混合在一起。
嗯,你没有提到你正在使用的编程语言,但我会将标记添加到工作多行:
/<div class=\"report-content\">(.*?)<\/div>/s
在我看来,也没有理由使用\s
所以我用空格替换。