URL Regex JavaScript | Match HTTP/HTTPS Protocol code

Checking whether a single string is itself a valid URL or not.

URL Regex to ensure URL starts with HTTP/HTTPS:

https?:\/\/(www\.)?[[email protected]:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

Not require HTTP protocol

[[email protected]:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

URL Regex JavaScript Examples

HTML example code:


		var expression = /[[email protected]:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi;
		var regex = new RegExp(expression);
		var tURL = 'www.eyehunts.com';

		if (tURL.match(regex)) {
			alert("Successful match");
		} else {
			alert("No match");


URL Regex JavaScript

Do comment if you have any doubts and suggestion on this JS URL topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.