Regular Expressions 101

Community Patterns

HTML Anchor to Markdown Inline Link

1

Regular Expression
PCRE (PHP <7.3)

/
<a[^>]*?href=(?|"([^"]*?)"|'([^']*?)').*?>(.*?)<\/a>
/
gsi

Description

Extracts the href and title values from an anchor tag to be placed into an inline Markdown link.

Submitted by Mike Johnson - 10 years ago