I need to get the first word after slash in a url in javascript, I assume using a regex would be ideal.
Here\'s an idea of what the URLs can possibly look like :
Here is the quick way to get that in javascript
var urlPath = window.location.pathname.split("/"); if (urlPath.length > 1) { var first_part = urlPath[1]; alert(first_part); }