URL Regex — Match and Break Down Links
Debug JavaScript regular expressions live: highlighted matches, capture groups, flags, and replacement preview.
Result
This page starts with a URL pattern that both finds links and dissects them: (?<protocol>https?):\/\/(?<host>[^\s\/?#]+)(?<path>\/[^\s?#]*)?(?<query>\?[^\s#]*)?. Each match is split into four named groups — protocol, host, path and query — so you see not just that a link matched, but which piece of it went where.
The character classes here do the real work: [^\s\/?#]+ means "everything up to the next slash, question mark or hash", which is how the host is separated from the path and the path from the query string. Note that ftp://old.server.net in the sample stays unmatched because the protocol group only allows http or https — extend the alternation if you need more schemes.
Paste your own text — a log file, a Markdown document, an HTML fragment — and watch the highlights update live. The replacement field understands group references, so you can rewrite every matched link, for example wrapping it as [$&] or reducing it to $<host>.