regular expression for link

前端 未结 2 761
攒了一身酷
攒了一身酷 2021-01-28 00:13

i need to trim this string -> http://hokuspokus/ixdebude/ix and i exactly Need this part of the string /ixdebude/ix

I have 2 expressions to solve my P

2条回答
  •  一整个雨季
    2021-01-28 00:33

    You could try this

    var parser = document.createElement('a');
    parser.href = "http://example.com:3000/pathname/?search=test#hash";
    
    parser.protocol; // => "http:"
    parser.hostname; // => "example.com"
    parser.port;     // => "3000"
    parser.pathname; // => "/pathname/"
    parser.search;   // => "?search=test"
    parser.hash;     // => "#hash"
    parser.host;     // => "example.com:3000"
    

    https://gist.github.com/jlong/2428561

提交回复
热议问题