Get relative URL from absolute URL

后端 未结 8 1901
自闭症患者
自闭症患者 2020-12-03 04:42

I want to get the relative URL from an absolute URL in JavaScript using regex and the replace method.

I tried the following but it is not working:

va         


        
8条回答
  •  既然无缘
    2020-12-03 05:23

    don't forget that \ is an escape character in strings, so if you would like to write regex in strings, ensure you type \ twice for every \ you need. Example: /\w/"\\w"

提交回复
热议问题