100% Client-Side β’ 0 B Data Leaves Browser
web
HTTP/HTTPS URL Validation Regex
Validates web URLs including domain, optional port, and query parameter path.
Regular Expression Pattern:
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/i
Valid Match Example:
https://devtransform-hub.vercel.app/tools/
Invalid / Non-Match Example:
htp://invalid-url
Regex Syntax Breakdown & Explanation
- β’^https?:\/\/ : Matches http or https protocol
- β’(?:www\.)? : Optional www prefix
- β’[-a-zA-Z0-9...]{1,256} : Domain name
- β’\.[a-zA-Z0-9()]{1,6} : Valid TLD extension
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/i;
const isValid = regex.test("https://devtransform-hub.vercel.app/tools/");
console.log(isValid); // truePython (re)
import re
pattern = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
match = re.match(pattern, "https://devtransform-hub.vercel.app/tools/")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$`)
fmt.Println(re.MatchString("https://devtransform-hub.vercel.app/tools/"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/i. Validates web URLs including domain, optional port, and query parameter path.