Code & Markup · In-Browser Regular Expression Lab
Markdown Link Regex — Extract [Anchor Text](URL) Pairs
Captures anchor text and target URL from Markdown link syntax `[text](url)`.
Flags:
//g
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:[Castov](https://castov.com)
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
[Castov](https://castov.com) Pass
[Documentation](https://castov.com/tools) Pass
Expected Invalid Samples (Must Reject)
plain text Rejected (Pass)
[unclosed link Rejected (Pass)
https://example.com Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /\[([^\]]+)\]\((https?:\/\/[^\s\)]+)\)/g;
const text = "[Castov](https://castov.com)";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Group 1 captures the human-readable link text; Group 2 captures the web hyperlink. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| \[([^\]]+)\] | Link Text Group | Captures everything inside square brackets. |
| \((https?:\/\/[^\s\)]+)\) | URL Group | Captures HTTP/HTTPS web address inside parentheses. |
Frequently Asked Questions
Does this match internal relative links?
Related Regular Expressions
Browse All 40 PatternsCode & Markup
HTML Tags Matcher & Stripper
Matches HTML markup tags for sanitization, stripping, or token extraction.
/<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s+[^>]*?)?\/?>/gTest regex
Network & Web
HTTP & HTTPS URL Validation
Matches fully qualified URLs starting with http:// or https://, including subdomains, paths, ports, and query parameters.
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(?:\.[a-zA-Z0-9()]{1,6})?(?::[0-9]{1,5})?\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/iTest regex
Data & Formatting
URL Slug Matcher
Matches lowercase alphanumeric strings separated by single hyphens, ideal for SEO permalinks.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/Test regex