Regex for Markdown Link
Matches Markdown links in [text](url) format.
Pattern
/\[([^\]]+)\]\(([^)]+)\)/g Live Tester
Enter a string to test
Examples
The g flag makes the pattern apply special matching behavior and match globally.
✓ [Google](https://google.com)
✓ [click here](page.html)
✗ [incomplete](
✗ (no brackets)
Pattern Breakdown
\[ — opening bracket
([^\]]+) — link text
\]\( — bracket + paren
([^)]+) — URL
\) — closing paren
Code Snippets
Javascript
const m = /\[([^\]]+)\]\(([^)]+)\)/g.exec("[Google](https://google.com)");
// m[1] = "Google", m[2] = "https://google.com" Python
m = re.search(r"\[([^\]]+)\]\(([^)]+)\)", "[Google](https://google.com)")
# m.group(1) = "Google", m.group(2) = "https://google.com" Php
preg_match('/\[([^\]]+)\]\(([^)]+)\)/', "[Google](https://google.com)", $m);
// $m[1] = "Google", $m[2] = "https://google.com" Related Patterns
Frequently Asked Questions
What is the regex for Markdown Link?▾
The regex pattern for Markdown Link is /\[([^\]]+)\]\(([^)]+)\)/g. Matches Markdown links in [text](url) format.
How do I use the Markdown Link regex in JavaScript?▾
In JavaScript you create the pattern with a regex literal or the RegExp constructor and call .test() to check a string against it. A ready-to-copy example is shown in the Code Snippets section above, alongside Python and PHP versions.
What does the Markdown Link pattern match?▾
It matches strings like [Google](https://google.com); it rejects strings like [incomplete](. See the Examples section above for the full list of matching and non-matching cases.