Markdown Link
Match Markdown links [link text](url) and capture both the display text and the URL.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\[([^\\]]+)\\]\\(([^)]+)\\)", "g");
const input = "[RegexPro](https://www.regexpro.dev)";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\[([^\]]+)\]\(([^)]+)\)")
input_text = "[RegexPro](https://www.regexpro.dev)"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\[([^\]]+)\]\(([^)]+)\)`)
input := `[RegexPro](https://www.regexpro.dev)`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\[([^\]]+)\]\(([^)]+)\) (flags: g)Raw source: \[([^\]]+)\]\(([^)]+)\)
How it works
Examples
Input
[RegexPro](https://www.regexpro.dev)Matches
[RegexPro](https://www.regexpro.dev)
Input
[Click here](https://example.com/path)Matches
[Click here](https://example.com/path)
Common use cases
- •Markdown parser implementation
- •Link extraction from .md files
- •Documentation link checking
- •Static site generator tooling
Related patterns
Markdown Image
Text ProcessingMatches Markdown image syntax .
Markdown Heading
Text ProcessingMatches markdown ATX-style headings (# through ######).
Java Package Declaration
Text ProcessingMatch Java `package com.example.app;` declarations and capture the dotted package path.
JSON Key-Value Pair (Simple)
Text ProcessingExtract simple `"key": value` pairs from JSON-ish text (strings, numbers, booleans, null).
Related concepts
Lazy vs. Greedy Quantifiers
ConceptGreedy quantifiers (*, +) consume as much as possible before backtracking. Lazy quantifiers (*?, +?) consume as little as possible.
Capturing Groups and Non-Capturing Groups
ConceptParentheses group tokens and capture the matched substring. (?:...) groups without capturing — use it when you want grouping for quantifiers or alternation but don't need the submatch.
How to Escape Regex Special Characters
How-toBackslash-escape any of .^$*+?()[]{}|\ to match them literally. When building a regex from user input, use a full-escape helper function.