regexhelper
Test a pattern. Copy a ready-made one. No signup.

Regex to Match a Markdown Link

Copy the pattern, paste your Markdown below, and watch it highlight every inline link. Below the tester: how the two capture groups give you text and URL.

/ /

What this pattern matches

This matches a Markdown inline link and captures the link text in group 1 and the URL in group 2.

How it works, part by part

\[([^\]]+)\] — the square brackets and the text inside (group 1).

\(([^)]+)\) — the parentheses and the URL inside (group 2).

Limitations

It does not handle titles like [text](url "title") as a separate group, nested brackets, or reference-style links [text][ref]. It covers the common inline case.

FAQ

How do I get the text and URL separately?

Use the capture groups: group 1 is the text, group 2 is the URL.

Does it match reference-style links?

No. This matches inline [text](url) links only, not [text][ref] style.