如何将 HTML 组代码与正则表达式匹配

问题描述 投票:0回答:0

我正在与正则表达式作斗争,但进展不顺利。

假设我有这个:

<div class="abc">
    <div class="def">
        <div class="ghi">
            <div class="jkl">
                ...
            </div>
        </div>
    </div>
</div>

我想匹配

<div class="def">
和最后一个之前的
</div>
。我怎样才能用正则表达式做到这一点?我使用这个网站寻求帮助:https://regex101.com/

that's what I have now

这是我的正则表达式代码:

/<div class="def">(.*)<\/div>/isU

但是它不会匹配最后一个之前的

</div>

任何帮助表示赞赏。

谢谢

html regex regex-group
© www.soinside.com 2019 - 2024. All rights reserved.