Shouldn't this RegExp work?

后端 未结 4 450
醉酒成梦
醉酒成梦 2021-01-27 02:37
testString = \"something://something/task?type=Checkin\";

patt = new RegExp(\"something\\/(\\w*)\\?\");
match = patt.exec(testString);
document.querySelector(\'#resultR         


        
4条回答
  •  一向
    一向 (楼主)
    2021-01-27 03:17

    try with this: var pat = /something:\/\/(?:[^\/]+\/)+(\w+)\?(\w+=\w+)/;

    it can match string such as:

    something://something/task?type=Checkin
    something://something/foo/task?type=Checkin
    something://something/foo/bar/task1?type3=Checkin4
    

提交回复
热议问题