correct a bad generated link using Javascript

前端 未结 4 1505
灰色年华
灰色年华 2021-01-26 12:36

I have a system that dynamically generates links. but the html links are displayed like this :



        
4条回答
  •  迷失自我
    2021-01-26 13:15

    Within your process you can use regex to extract the url from the href string:

    const string = "Page Example";
    const url = string.match(/(\/)[\w-]*(?=&)/)[0];
    console.log(url);

提交回复
热议问题