Skip to main content
Regexflux

HTTP/HTTPS URL

intermediate

Matches URLs starting with http:// or https://.

urlvalidationwebhttp

Pattern

/https?://[\w.-]+(?:\.[a-zA-Z]{2,})(?:[/\w.-]*)*(?:\?[\w=&.-]*)?(?:#[\w-]*)?/gi

Try It

0 of 6 strings matched

Explanation

Matches URLs with http or https protocol, domain with TLD, optional path segments, query string parameters, and fragment identifiers.

Test Strings

Matching

  • https://example.com
  • http://sub.domain.co.uk/path?q=1#top
  • https://api.example.com/v2/users

Non-matching

  • ftp://files.com
  • example.com
  • not-a-url

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /https?:\/\/[\w.-]+(?:\.[a-zA-Z]{2,})(?:[\/\w.-]*)*(?:\?[\w=&.-]*)?(?:#[\w-]*)?/gi;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Common Variations

HTTPS only

https://[\w.-]+(?:\.[a-zA-Z]{2,})(?:[/\w.-]*)*

Matches only HTTPS URLs

Related Patterns