Regex To Match Markdown-style URL Links

A regular expression to match a markdown-style URL link with or without title text.

/\[([^\]]+)\]\(([^)"]+)(?: \"([^\"]+)\")?\)/

Matches:

  • [Regex](https://regexpattern.com/)
  • [Regex](https://regexpattern.com/1.html)
  • [Regex](https://regexpattern.com/ “Link Title”)
  • [Managed Disks](#managed-disks)
  • [Managed Disks](../linux/overview.md#managed-disks)

Non-matches:

  • ## <a name=”anchortext” />Header text
  • https://regexpattern.com/
  • [Regex][https://regexpattern.com/]

See Also:

Regex Is Copied!