fangwenxue

求个正则

  •  
  •   fangwenxue · Nov 21, 2021 · 1545 views
    This topic created in 1768 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   ·   Privacy   ·   Solana   ·   2537 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 08:49 · PVG 16:49 · LAX 01:49 · JFK 04:49
    ♥ Do have faith in what you're doing.