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

Input
 and Matches
