Template:Match/doc

Revision as of 05:59, 16 July 2023 by Saucy (talk | contribs) (doc)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

{{match|string|pattern|init=optional|ifMatch=optional|ifNo=optional}}

This template looks for the first match of the pattern in the string and returns it. It uses the mw.ustring.match() function to do this. The pattern must be a Lua pattern. Lua patterns are essentially a nerfed version of regular expressions.

TemplateData edit

Looks for the first match of a pattern in a string and returns it.

Template parameters

ParameterDescriptionTypeStatus
String1

The string to search.

Stringrequired
Pattern2

The pattern that the string should be searched for. Must be a Lua pattern, which is like a regular expression but nerfed.

Stringrequired
initinit

The position in the string to start searching in from.

Default
1
Numberoptional
ifMatchifMatch

What the template outputs if a match is found. If this parameter is "MATCH" or left undefined, then the match itself would be returned.

Default
(the match that was found)
Stringoptional
ifNoifNo

What the template outputs if no match is found.

Default
(empty string)
Stringoptional