Module:User:Theknightwho/template regex

From Wiktionary, the free dictionary
Jump to navigation Jump to search

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

]==]