Regex for Markdown Link
This regex matches Markdown-style links in the format [text](url). It captures both the link text and the URL in separate groups. Markdown links are used in README files, documentation, static site generators, and many content management systems. The pattern works for inline links but does not match reference-style links.
\[([^\]]+)\]\(([^)]+)\) What is the regex pattern for Markdown Link?
The regex pattern for Markdown Link is \[([^\]]+)\]\(([^)]+)\) with the g flag. This regex matches Markdown-style links in the format [text](url). It captures both the link text and the URL in separate groups. Markdown links are used in README files, documentation, static site generators, and many content management systems. The pattern works for inline links but does not match reference-style links. This pattern is commonly used for markdown parsing and link extraction from docs.
Test Examples
[Click here](https://example.com) [Click here](https://example.com) [Docs](./api/readme.md) [Docs](./api/readme.md) plain text Common Uses
- ✓ Markdown parsing
- ✓ Link extraction from docs
- ✓ Content migration
- ✓ Documentation analysis
Variations
With optional title
\[([^\]]+)\]\(([^)]+?)(?:\s+"([^"]*)")?\) Captures optional title: [text](url "title")
Reference-style
\[([^\]]+)\]\[([^\]]*)\] Matches [text][ref] reference links
Image links
!\[([^\]]*)\]\(([^)]+)\) Matches Markdown images 
Frequently Asked Questions
Does this match Markdown images?
No, Markdown images use an exclamation mark prefix: . Use the 'Image links' variation to match those. This pattern only matches text links.
What are reference-style links?
Reference-style links separate the link text from the URL: [text][id] with [id]: url defined elsewhere. This pattern matches inline links only. Use the 'Reference-style' variation for the other format.
Can nested brackets cause issues?
Yes, if the link text contains brackets, this simple pattern may not match correctly. For production Markdown parsing, use a dedicated library like marked, remark, or markdown-it.