Regular Expressions 101

Community Patterns

Wikilink

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\[\[([^#\[\]<>{}|_]*)[|#]?[^#\[\]<>{}|_]*\]\]
/
gm

Description

Matches internal Wikimedia/Wikipedia links and captures the article name i.e. [[substance theory|substance]] captures substance theory

Submitted by anonymous - 22 days ago