var expression = /[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi; var regex = new RegExp(expression); var t = 'www.google.com'; if (t.match(regex)) { alert("Successful match"); } else { alert("No match"); }