utgplg
Last Updated: February 25, 2016
·
2.663K
· agam360
B6ff0bfd7521b66a4284f8740936e016

Regex Full URL -> Base URL

Full url:
http://stackoverflow.com/questions/6038061/regular-expression-to-find-urls-within-a-string

Base:

stackoverflow.com

Regex:
(http(s)?:\/\/)|(\/.*){1}

Example in JavaScript:

function toBaseURL(fullURL){
    return fullURL.replace(/(http(s)?:\/\/)|(\/.*){1}/g, '');
}
Say Thanks
Respond

1 Response
Add your response

9766
Default profile 1 normal

Thank you very much! It works

over 1 year ago ·