Correct way to do a string replace with regex in javascript? -


i newbie regex , expression appears backwards or opposite of trying do. have string, in case url, , want replace , including last forward slash empty string. have

"http://www.sweet.com/member/other".replace(/[^/]+$/, "") 

which opposite of want. proper expression results i'm seeking? in case end string "other"? help

regexr example

you want regex matches beginning of string, followed many characters possible, followed slash:

/^.*\// 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -