Text Processingflags: g
Markdown Image
Matches Markdown image syntax .
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("!\\[([^\\]]*)\\]\\(([^)]+)\\)", "g");
const input = "";
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
pyPython
import re
pattern = re.compile(r"!\[([^\]]*)\]\(([^)]+)\)")
input_text = ""
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
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`!\[([^\]]*)\]\(([^)]+)\)`)
input := ``
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
regexengine-agnostic
!\[([^\]]*)\]\(([^)]+)\) (flags: g)Raw source: !\[([^\]]*)\]\(([^)]+)\)
How it works
`!\[([^\]]*)\]` captures the alt text inside brackets. `\(([^)]+)\)` captures the URL in parentheses.
Examples
Input
Matches

Input
 and Matches

Common use cases
- •Markdown rendering
- •Image extraction
- •Link validation
Related patterns
Markdown Link
Text ProcessingMatch Markdown links [link text](url) and capture both the display text and the URL.
Markdown Heading
Text ProcessingMatches markdown ATX-style headings (# through ######).
Non-Capturing Group (Image URL)
Text ProcessingUse non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.
Python f-String Expression
Text ProcessingMatch `{expression}` placeholders inside Python f-strings (or any single-brace template syntax).