Skip to content

URL Regex JavaScript | Match HTTP/HTTPS Protocol code

  • by

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 = '';

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


URL Regex JavaScript

Do comment if you have any doubts or suggestions 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

Your email address will not be published.

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