Parse URL with Javascript [duplicate]

You can use

var pagenum = location.pathname.match(/\/page\/(.*)/)[1];

It will extract anything past ‘/page/’ in your URL;

Leave a Comment