DevTools
Back to Regex Tester

URL / HTTP Regex Pattern

Match HTTP and HTTPS URLs using regex. Includes protocol, domain, path, and query string matching with ready-to-use patterns.

The Pattern

/https?://[\\w\\-._~:/?#\\[\\]@!$&'()*+,;=%]+/g

How It Works

TokenMeaning
httpLiteral "http" string
s?Optional "s" for HTTPS
://Literal "://" separator
[\\w\\-._~:/?#\\[\\]@!$&'()*+,;=%]+One or more valid URL characters including path, query, and fragment

Test Cases

https://example.comMatch
http://test.org/path?q=1Match
https://sub.domain.co.uk/page#sectionMatch
ftp://files.example.comNo match
not-a-urlNo match
://missing-protocol.comNo match

Code Examples

javascript
const urlRegex = /https?:\/\/[\w\-._~:/?#[\]@!$&'()*+,;=%]+/g;
const text = "Visit https://example.com/path?q=1 or http://test.org";
const matches = text.match(urlRegex);
console.log(matches); // ["https://example.com/path?q=1", "http://test.org"]
python
import re
url_regex = r"https?://[\w\-._~:/?#\[\]@!$&'()*+,;=%]+"
text = "Visit https://example.com/path?q=1 or http://test.org"
matches = re.findall(url_regex, text)
print(matches)  # ['https://example.com/path?q=1', 'http://test.org']

Common Use Cases

Related Patterns

Want to test this pattern with your own data?

Try this pattern in Regex Tester →