Editing
Template:Match/doc
Jump to navigation
Jump to search
β οΈ
Warning:
You are not logged in.
Your IP address will be publicly visible
if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username instead of your IP, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Lua|Match}} <code>{{match|''string''|''pattern''|init=''optional''|ifMatch=''optional''|ifNo=''optional''}}</code> This template looks for the first match of the ''pattern'' in the ''string'' and returns it. It uses the [[mediawikiwiki:Extension:Scribunto/Lua reference manual#mw.ustring.match|mw.ustring.match()]] function to do this. The pattern must be a '''[[mediawikiwiki:Extension:Scribunto/Lua reference manual#Patterns|Lua pattern]]'''. Lua patterns are essentially a nerfed version of {{w|regular expressions}}. == TemplateData == <templatedata> { "params": { "1": { "label": "String", "description": "The string to search.", "type": "string", "required": true }, "2": { "label": "Pattern", "description": "The pattern that the string should be searched for. Must be a Lua pattern, which is like a regular expression but nerfed.", "type": "string", "required": true }, "init": { "description": "The position in the string to start searching in from.", "type": "number", "default": "1" }, "ifMatch": { "description": "What the template outputs if a match is found. If this parameter is \"MATCH\" or left undefined, then the match itself would be returned.", "type": "string", "default": "(the match that was found)" }, "ifNo": { "description": "What the template outputs if no match is found.", "type": "string", "default": "(empty string)" } }, "description": "Looks for the first match of a pattern in a string and returns it." } </templatedata>
Summary:
Please note that all contributions to Irony Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Irony Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Lua
(
edit
)
Template:Ombox
(
view source
) (protected)
Template:W
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:No globals
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Template
Discussion
English
Views
Read
Edit source
View history
More
Purge cache
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information
Page values