llhh

问个正则表达式的问题

  •  
  •   llhh · Nov 24, 2014 · 2609 views
    This topic created in 4361 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
    imn1
    Nov 24, 2014❤️1
    1
    class="(?:g|c-showurl)">(.+?)</span>
    imn1
    imn1
    Nov 24, 2014❤️1
    2
    class="(?:g|c-showurl)"[^>]*?>(.+?)</span>
    这样保险一点,因为不能确定class是最后一个属性
    xylophone21
    xylophone21
    Nov 24, 2014
    3
    你想怎么处理
    <span class = "c-showurl">...<sth class="c-showurl">...</sth></span>
    ?

    纯正则角度
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5045 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 06:53 · PVG 14:53 · LAX 22:53 · JFK 01:53
    ♥ Do have faith in what you're doing.