function isValidURL(string) {
var res = string.match(/(http(s)?://.)?(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}([-a-zA-Z0-9@:%_+.~#?&//=]*)/g);
return (res !== null)
};
var testCase1 = "http://en.wikipedia.org/wiki/Procter_&_Gamble";
alert(isValidURL(testCase1));
const isUrl = string => {
try { return Boolean(new URL(string)); }
catch(e){ return false; }
}