~/regex-tester

Match URLs with regex

A regex that captures http and https URLs in free text. Covers query strings, fragments, ports, and unicode-safe alternatives.

# pattern

/https?://[\w./?=&%#:-]+/gi

→ Open in regex tester (pre-filled)

# how it works

Matches http or https (the `s?` makes the s optional), then `://`, then a run of URL-safe characters. The character class accepts letters, digits, dots, slashes, question marks, equals, ampersands, percent signs, hashes, colons, and hyphens — covering query strings, fragments, and port numbers.

# sample input

See https://bytefork.tools and http://example.com/path?q=1#section or check https://docs.python.org:8080/3/library/re.html for details.

# pitfalls

# other patterns