【问题标题】:Select img tags which are having text logo any where in the html tag选择在 html 标记中任何位置具有文本徽标的 img 标记
【发布时间】:2020-01-24 19:39:36
【问题描述】:
<img class="logo" src="/logo.png">
<img src="/product.png" id="logo">
<img 
   src="/product.png" 
   id="logo"
/>


<img class="with-text" src="            /portal-resource/portal-theme-images/regence/identity/regence-sun-cs.svg
    " alt="Regence-cs">


<img class="with-text" src="            /portal-resource/portal-theme-images/regence/identity/regence-sun-cs.svg
    " alt="Regence-cs logo">

我的试用版可在 A rubular trial 获得

请指导我选择在整个标签中的任何位置都有徽标文本的图像标签

【问题讨论】:

    标签: html regex ruby image


    【解决方案1】:

    我已经检查过了并且工作正常:

    &lt;img\s+.*?src=['"]([^"']+).*? alt=\"(.*)logo(.*)\"&gt;

    用这个模式尝试一次,也许它适合你的用例......

    【讨论】:

      【解决方案2】:

      试试正则表达式:&lt;img(?=[^&gt;]*logo)[^&gt;]*\/?&gt;

      Demo

      【讨论】:

        猜你喜欢
        • 2015-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-14
        • 2019-06-03
        • 1970-01-01
        • 2011-01-27
        相关资源
        最近更新 更多