I could not understand the following code:
var req = "google.com/?x=value&y=another";
req = req.replace(/\/?(?:\?.*)?$/, '');
console.log(req);
The above code prints google.com, its removing the query parameters from the string.
can anyone explain me how the replace function doing this task?