invite
V2EX  ›  问与答

浏览器页面搜索的时候,能不能加一个选型,提供正则搜索?

  •  
  •   invite · Mar 12, 2015 · 2856 views
    This topic created in 4123 days ago, the information mentioned may be changed or developed.

    目前有没有浏览器支持? 麻烦推荐一下。

    1 replies    2015-03-12 14:46:10 +08:00
    saber000
        1
    saber000  
       Mar 12, 2015
    用控制台吧,貌似都能支持.

    function rex_find(pattern){
    var regx = new RegExp(pattern, "igm");
    var results = [];
    while ((result = regx.exec(document.body.innerText)) != null){
    results.push(result[0]);
    }
    return results;
    }

    rex_find("\\d+")
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4643 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 420ms · UTC 04:03 · PVG 12:03 · LAX 21:03 · JFK 00:03
    ♥ Do have faith in what you're doing.