How to remove the names of the parameters ownerUUID and petUUID from the line owner/:ownerUUID/pets/:petUUID petUUID ?
makeRequestURL(url, params) { console.log("makeRequestURL", url.match(/:(.*)/g)); } How to remove the names of the parameters ownerUUID and petUUID from the line owner/:ownerUUID/pets/:petUUID petUUID ?
makeRequestURL(url, params) { console.log("makeRequestURL", url.match(/:(.*)/g)); } var url="owner/:ownerUUID/pets/:petUUID"; console.log(url.match(/\/:[^\/]+/g).map(function(val) { return val.substr(2); })); Here, the regular starts the selection with the substring /: and further until it encounters a slash ( [^\/]+ ), and in the map () the unnecessary characters are deleted ( /: .
Source: https://ru.stackoverflow.com/questions/584491/
All Articles