I have this as a string
http://steamcommunity.com/id/user/
And when I use this regex pattern : [^\/]+\/$ I get this result is
user/
I'm trying to negate the last / so i can get
user
How can I accomplish this?
I have this as a string
http://steamcommunity.com/id/user/
And when I use this regex pattern : [^\/]+\/$ I get this result is
user/
I'm trying to negate the last / so i can get
user
How can I accomplish this?
Try this code:
var string = 'http://steamcommunity.com/id/user/'
document.body.innerHTML = string.match(/([^/]+)\/$/)[1]
I added a capturing group to capture the user folder.
Since that was the 1st capturing group, I selected the item at index 1 of the returned array from string.match()
var string = 'http://steamcommunity.com/id/user/'
document.body.innerHTML = string.match(/([^/]+)\/$/)[1]