⭐ 0

URL Regex — Match and Break Down Links

Debug JavaScript regular expressions live: highlighted matches, capture groups, flags, and replacement preview.

Processed entirely in your browser — nothing you enter here is ever uploaded.

Supports $1, $2 and named references like $<name>; $& inserts the whole match. Leave empty to hide the preview.

Processing... 0%

Result

About this tool

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>.

Example. The pattern \d+ with no flags, applied to ab12cd34, highlights the matches 12 and 34.

Limit. Matching stops after 5000 hits, and the on-page list shows only the first 200.