Module:User:Theknightwho/template regex
Jump to navigation
Jump to search
- This module lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Theknightwho, for their own experimentation. Items in this module may be added and removed at Theknightwho's discretion; do not rely on this module's stability.
--[==[
/(?:{{(?:
{(?<main>(?(?={){{(?>{\g<main>(?>}}}|\z)|\g<main>(?>}}(?!})|\z)))(?:
[^\n\-<\[{|}]++|
\|(?>[^\n\-<=\[{}]++|\n(?!==)|\g<blocks>|[^=}]|}(?!}))*=?|
(?<blocks>(?=[\n\-<[{])(?>
\[\[(?>[^\n\-<[\]{]++|\g<blocks>|[^\]]|](?!]))*(?>]]|\z)|
{{(?<temparg>(?>{\g<main>(?>}}}|\z)|\g<main>(?>}}|\z)))|
<(?<tag>(?>
!--\X*?(?>-->|\z)|
\/?(?>includeonly|noinclude|onlyinclude)(?>>|\/>|\s[^>]*>)|
(?<tagname>(?>categorytree|ce|charinsert|chem|dynamicpagelist|gallery|graph|hiero|imagemap|indicator|inputbox|langconvert|mapframe|maplink|math|nowiki|phonos|poem|pre|ref|references|score|section|source|syntaxhighlight|talkpage|templatedata|templatestyles|thread|timeline))(?>>|\/>|\s[^>]*>)(?>(?<=\/>)|\X*?<\/\k<tagname>\s*>)
))|
\n=(?>[^\n\-<[{]++|(?!\n)\g<blocks>|\N)*|
-{(?>{\g<temparg>|(?>[^\n\-<[{}]++|\g<blocks>|[^}]|}(?!-))*(?>}-|\z))
))|
[^|}]|
}(?!})
)*(*PRUNE))}|
\g<main>
)}}|<\g<tag>(*SKIP)(*F))/gix
]==]