Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get domain name with regex

const urls = [
  'www.abc.au.uk',
  'https://github.com',
  'http://github.ca',
  'https://www.google.ru',
  'http://www.google.co.uk',
  'www.yandex.com',
  'yandex.ru',
  'yandex',
  'devmaster.auxitaplatform.com',
]

urls.forEach(url => console.log(url.replace(/.+//|www.|..+/g, '')))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #domain #regex
ADD COMMENT
Topic
Name
9+6 =