zddewe
V2EX  ›  问与答

讨教正则表达式

  •  
  •   zddewe · Nov 16, 2017 · 1763 views
    This topic created in 3276 days ago, the information mentioned may be changed or developed.
    5 replies  •  2017-11-16 13:00:08 +08:00
    Carseason
    Carseason
    Nov 16, 2017 via iPhone
    1
    分割或者替换
    oott123
    oott123
    Nov 16, 2017
    2
    ^https://www\.google\.[a-z.]+/
    boboliu
    boboliu
    Nov 16, 2017 via Android
    3
    split 一把梭完事,要什么正则。。。

    btw,正则也很好写,老哥咱能不能自学一下。。。

    最后,https://u.bobiji.com/tiwen
    freedomSky
    freedomSky
    Nov 16, 2017
    4
    只会 sed 版,

    sed 's/https:\/\/www.google.[^/]*\/beijing/https:\/\/www.google.com\/beijing/'


    case1:
    echo "123 https://www.google.co.kr/beijing 456" | sed 's/https:\/\/www.google.[^/]*\/beijing/https:\/\/www.google.com\/beijing/' -

    case2:
    echo "123 https://www.google.co.kr/abeijing 456" | sed 's/https:\/\/www.google.[^/]*\/beijing/https:\/\/www.google.com\/beijing/' -
    hapboy
    hapboy
    Nov 16, 2017
    5
    function (str) {
    return str.replace(/https:\/\/www\.google\.(.*?)\//g, 'https://www.google.com/')
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2622 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 14:39 · PVG 22:39 · LAX 06:39 · JFK 09:39
    ♥ Do have faith in what you're doing.