Regex for markdown link
/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g
Matches
Examples
Note
Group 1 is the text, group 2 the URL, group 3 the optional title.
Matches in the example
"[the docs](https://example.com/docs \"Docs\")""[home](/)"
Token by token
\[the character “[”(a capturing group[^\]]+any character except the character “]”, one or more times, as many as possible)end of group\]the character “]”\(the character “(”(a capturing group[^)\s]+any character except “)” or a whitespace character, one or more times, as many as possible)end of group(?:a group, not capturing\s+a whitespace character, one or more times, as many as possible"the character “"”(a capturing group[^"]*any character except “"”, zero or more times, as many as possible)end of group"the character “"”)?end of group, whole group optionally\)the character “)”
Other patterns
- Email address
- URL
- IPv4 address
- UUID
- Hex color
- Date (YYYY-MM-DD)
- Time (24-hour)
- US phone number
- Phone number (E.164)
- US ZIP code
- Credit card number
- URL slug
- Username
- Strong password
- HTML tag
- Semantic version
- MAC address
- JSON Web Token
- Hashtag
- @mention
- Number
- Leading and trailing whitespace
- Repeated word
- Blank lines
- Markdown link
- Quoted string
- Domain name
- File extension
- Base64
- Trailing comma