March 18, 201511 yr Hello all, I'm trying to get the last two sections of a pathname using jquery's exec function. For example: http:/localhost/sites/testsite/page I can retrieve the last item by using : var path = window.location.pathname; var result = /[^/]*$/.exec(pathname)[0]; And then displaying 'page' by printing the variable result. I've tried using: var path = window.location.pathname; var result = /[^/]*$/.exec(pathname)[1]; I've tried different combinations and of this but none of them seem to work. Can anyone help?
Create an account or sign in to comment