用正则表达式查找第一个向后匹配

时间:2020-08-14 13:17:04

标签: regex

我正在使用正则表达式。

我想匹配给定图像的sl块的高度。 在示例中,我有两个图像,分别为image1.png和image2.png。

当我在后面使用时,它总是与第一个高度匹配,但是我想匹配与图像所在的sl块相对应的那个高度。

使用示例中的代码,如果选择了image1.png,则正则表达式应返回300.45678,对于image2.png,则应返回300。

<div class="sl-block" data-block-type="img" style="width: 600px; height: 300.45678px; left: 0px; top: 0px;" data-name="img-b59ef5">
  <div class="sl-block-content" style="z-index: 11;">
    <img seamless="" scrolling="no" width="600" height="400" frameborder="0" src="/static/revealjs/img/test_size/image1.png" data-lazy-loaded="">
  </div>
</div>
<div class="sl-block" data-block-type="img" style="width: 600px; height: 300px; left: 0px; top: 0px;" data-name="img-b59ef5">
  <div class="sl-block-content" style="z-index: 11;">
    <img seamless="" scrolling="no" width="600" height="400" frameborder="0" src="/static/revealjs/img/test_size/image2.png" data-lazy-loaded="">
  </div>
</div>

0 个答案:

没有答案