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)); } 

    1 answer 1

     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 ( /: .