fangwenxue

求个正则

  •  
  •   fangwenxue · Nov 21, 2021 · 1329 views
    This topic created in 1666 days ago, the information mentioned may be changed or developed.
    我想要的结果 求个正则
    const s = '/hello'  // match[1] = hello
    const s = '/hello/abcd' // match[1] = hello // match[2] = /abcd
    const s = '/hello/' // match[1] = hello // match[2] = /
    
    console.log(s.match(/\/([^\/]+)?(.+)/i))
    
    1 replies    2021-11-21 21:56:00 +08:00
    jackmod
        1
    jackmod  
       Nov 21, 2021
    ^/([^/]*)(.*)$
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5443 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 09:09 · PVG 17:09 · LAX 02:09 · JFK 05:09
    ♥ Do have faith in what you're doing.