Regex library
Regular expression for HTTP URLs
A JavaScript regex that finds http and https URLs in text. Try it against mixed-case schemes and query strings.
https?:\/\/[^\s/$.?#].[^\s]*
Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.
Highlighted matches
How to use
- Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
- Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
- Paste your own corpus. Nothing is sent to a server.
- Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.
Extracting links from a blob of text is a different problem from validating a single URL field. This pattern looks for http:// or https:// and then a non-space run, which is what you want in a chat log or a markdown document.
It will not make a URL object valid. After a match, pass the string to the URL constructor if you need host, port, and query parsing.
What this pattern will not do
ftp, mailto, and protocol-relative //example.com links are ignored.
Trailing punctuation from prose (a comma or closing parenthesis) may be included; trim if needed.
The i flag lets HTTP:// match.
FAQ
Can I require https only?
Yes — drop the s? and write https:\/\/ instead of https?:\/\/.
Why not use the URL class alone?
URL needs a single candidate string. A regex is for finding candidates inside a larger document.
Is the sample text uploaded?
No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.