I'm not very good with regex
I want a regex expression that matches these:
http://localhost:3000/categories/football
http://localhost:3000/categories/football/2222/45444
http://localhost:3000/categories/tennis/45454
http://localhost:3000/categories/football/12
http://localhost:3000/categories/cricket/
basically, for all the above potential URL paths, I want the words after categories/ and before the second / to be returned
i.e.
football, football, tennis, football, cricket
I got this far:
(categories)/\w+
but obviously, that still includes categories
\w+part. You will get the content with$2var categories = location.pathname.split("/")[2];const [ protocol, host, page, topic, id, reference ] = route.replace( '://', '/' ).split( '/' ); return topic;