//g
  • 100% Free
  • No Sign-Up
  • No Credit Card
  • No Free Trial
  • No Pro Tier
  • No Watermarks

Nothing is uploaded. Just open it and start.

URL Regex

An http or https address with a host and an optional path, query and fragment, and no spaces.

/^https?:\/\/[^\s/$.?#][^\s]*$/i

Piece by piece

  1. ^the start of the text
  2. httpthe text “http”
  3. s?the character “s”, repeated optionally (0 or 1 time), as many as possible
  4. :\/\/the text “://”
  5. [^\s/$.?#]any character except a whitespace character (space, tab, line break…), “/”, “$”, “.”, “?”, “#”
  6. [^\s]*any character except a whitespace character (space, tab, line break…), repeated 0 or more times, as many as possible
  7. $the end of the text

Examples

TextResult
https://example.comMatches
http://example.com/path?q=1#topMatches
HTTPS://sub.example.org:8080/aMatches
example.comDoesn't match
ftp://example.comDoesn't match
http://Doesn't match
https://exa mple.comDoesn't match
  • It checks the shape only; for real parsing use the URL constructor (new URL(text)), which also handles ports and international names.

Other common patterns

Test any regular expression →

Frequently asked questions

How do I use this web address (url) regex in JavaScript?
Write it as /^https?:\/\/[^\s\/$.?#][^\s]*$/i and call re.test(text). It is anchored with ^ and $, so it checks the whole text; remove them to find it inside longer text (and add the g flag to find every one). The Code view writes it out for Python, Go and PHP too.
Is it a complete validator?
No regex is the whole story. It checks the shape only; for real parsing use the URL constructor (new URL(text)), which also handles ports and international names.
Can I try it on my own text?
Yes. The tester above already holds the examples; paste your own text over them and every match is highlighted as you type. Nothing is uploaded.

Spotted a bug or have a suggestion?

Found something broken, have an idea, or just want to say thanks about any of our tools? Every message reaches a real person.