I'm trying this in javascript
/\/.*?$/.exec('foo/bar/tar')[0]
I was expecting to get /tar
as result but getting /bar/tar
. As far as I understand non-greed regex would take the smallest match.
I'm circumventing this with myvar.split('/').reverse()[0]
but I couldn't understand what is going wrong with the regex.