Markdown Image in PY
Matches Markdown image syntax .
Try it in the PY tester →Pattern
regexPY
!\[([^\]]*)\]\(([^)]+)\) (flags: g)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+.
How the pattern works
`!\[([^\]]*)\]` captures the alt text inside brackets. `\(([^)]+)\)` captures the URL in parentheses.
Examples
Input
Matches

Input
 and Matches
