HTTP/HTTPS URL
intermediateMatches URLs starting with http:// or https://.
urlvalidationwebhttp
Pattern
/https?://[\w.-]+(?:\.[a-zA-Z]{2,})(?:[/\w.-]*)*(?:\?[\w=&.-]*)?(?:#[\w-]*)?/giTry 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
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full 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