Text Processingflags: g

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

jsJavaScript
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).

Pattern

regexengine-agnostic
\[([^\]]+)\]\(([^)]+)\)   (flags: g)

Raw source: \[([^\]]+)\]\(([^)]+)\)

How it works

Group 1 captures the link text inside square brackets (any chars except ]). Group 2 captures the URL inside parentheses (any chars except )).

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

Related concepts