If you already know that the path separator is /
(i.e. you are writing for a specific platform/environment), as implied by the example in your question, you could keep it simple and split the string by separator:
'/foo/bar/baz/asdf/quux.html'.split('/').pop()
That would be faster (and cleaner imo) than replacing by regular expression.
Again: Only do this if you're writing for a specific environment, otherwise use the path
module, as paths are surprisingly complex. Windows, for instance, supports /
in many cases but not for e.g. the \\?\?
style prefixes used for shared network folders and the like. On Windows the above method is doomed to fail, sooner or later.