You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/js/Vre1/Check whether a given value...

23 lines
530 B
JavaScript

function is_domain(str)
{
regexp = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/i;
if (regexp.test(str))
{
return true;
}
else
{
return false;
}
}
console.log(is_domain('www.example.com'));
console.log(is_domain('www.npm.co.uk'));
console.log(is_domain('http://www.example.com'));
console.log(is_domain('https://www.example.com'));
console.log(is_domain('www.example.com'));