llhh

问个正则表达式的问题

  •  
  •   llhh · Nov 24, 2014 · 2276 views
    This topic created in 4214 days ago, the information mentioned may be changed or developed.
    想把下面的正则表达式浓缩下只有一个(.+?)。
    class="g">(.+?)</span>|<span class="c-showurl">(.+?)</span>

    匹配class="g">开头儿或者<span class="c-showurl">(.+?)开头,</span>结尾的字符串

    多谢。
    3 replies    2014-11-24 16:57:40 +08:00
    imn1
        1
    imn1  
       Nov 24, 2014   ❤️ 1
    class="(?:g|c-showurl)">(.+?)</span>
    imn1
        2
    imn1  
       Nov 24, 2014   ❤️ 1
    class="(?:g|c-showurl)"[^>]*?>(.+?)</span>
    这样保险一点,因为不能确定class是最后一个属性
    xylophone21
        3
    xylophone21  
       Nov 24, 2014
    你想怎么处理
    <span class = "c-showurl">...<sth class="c-showurl">...</sth></span>
    ?

    纯正则角度
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3184 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 00:27 · PVG 08:27 · LAX 17:27 · JFK 20:27
    ♥ Do have faith in what you're doing.