Template:Match/doc

From Irony Wiki
Jump to navigation Jump to search

{{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 source]

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