You have an url pathname in this way and you would like to find some parameter into it:

url "/library/catalogue/sort/TITLE/page/1/books/n/chapters/n/articles/n"

/\/books\/(.*?)\//ig.test(location.pathname)
> ["/books/n/", "n"]

/\/books\/(.*?)\//ig.match(location.pathname)
> true

#1 – JavaScript Regex has to be reset. See this http://stackoverflow.com/questions/1520800/why-regexp-with-global-flag-in-javascript-give-wrong-results
for further informations.

Advertisement