I want to run a script that extracts an integer from the URL hash (#), or zero if no integer is found.
The URLs could be any of these formats:
- www.example.com/book/#page-cover
- www.example.com/book/#page-1
- www.example.com/book/#page-12
- www.example.com/book/#page-123
The above examples would return:
- 0
- 1
- 12
- 123
I'm running jQuery and looking for the cleanest way of doing this in either pure Javascript or jQuery.
Thanks in advance.