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 :
$url = 'http://mysite.com/section/subsection'; $path = parse_url($url, PHP_URL_PATH); $components = explode('/', $path); $first_part = $components[0];