I am trying to replace everything with a space after a question mark.
Suppose I have a line as shown below:
var str = "/root/Users?SkillId=201;"
Now I want to replace everything with an empty one after ?.
Expected Result: "/root/Users"
I tried the solution below:
var str = "/root/Users?SkillId=201;".replace(/[^? ]/g, ""); console.log(str);
I do not want to use a loop for this . Is there a better way to do this?
javascript
Learning-overthinker-confused
source share