HomeRegex LibraryMarkdown Image Syntax Regex
100% Client-Side β€’ 0 B Data Leaves Browser
web

Markdown Image Syntax Regex

Extracts alt text, image URL, and optional title from standard Markdown image tags.

Regular Expression Pattern:
/!\[([^\]]*)\]\(([^\s)]+)(?:\s+"([^"]+)")?\)/g
Valid Match Example:
![Company Logo](https://example.com/logo.png "Brand")
Invalid / Non-Match Example:
[Normal link](https://example.com)

Regex Syntax Breakdown & Explanation

  • β€’! : Image indicator exclamation mark
  • β€’\[([^\]]*)\] : Captures alt text within brackets
  • β€’\(([^\s)]+) : Captures image URL within parentheses
  • β€’(?:\s+"([^"]+)")?\) : Captures optional title quote before closing parenthesis

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /!\[([^\]]*)\]\(([^\s)]+)(?:\s+"([^"]+)")?\)/g;
const isValid = regex.test("![Company Logo](https://example.com/logo.png "Brand")");
console.log(isValid); // true
Python (re)
import re

pattern = r"!\[([^\]]*)\]\(([^\s)]+)(?:\s+"([^"]+)")?\)"
match = re.match(pattern, "![Company Logo](https://example.com/logo.png "Brand")")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`!\[([^\]]*)\]\(([^\s)]+)(?:\s+"([^"]+)")?\)`)
  fmt.Println(re.MatchString("![Company Logo](https://example.com/logo.png "Brand")"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /!\[([^\]]*)\]\(([^\s)]+)(?:\s+"([^"]+)")?\)/g. Extracts alt text, image URL, and optional title from standard Markdown image tags.