Skip to content

Instantly share code, notes, and snippets.

View erickweil's full-sized avatar

Erick Leonardo Weil erickweil

  • Brazil
View GitHub Profile
@davidhartsough
davidhartsough / url-regex-validator.md
Last active June 21, 2024 23:31
URL validator RegEx: code for JS and the HTML URL input pattern attribute to validate if the entry is a valid URL

My favorite URL RegEx

I spent way too long trying to dial this in, so I had to document my results and share them.

Check out the end result on RegExr: https://regexr.com/7fjmt

This RegEx is intended to accept nearly every valid URL, with a few exceptions; it intentionally excludes:

  • IP addresses
  • networks ranges, database/server addresses, ports