Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:String/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
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, along with other benefits.
Anti-spam check. Do
not
fill this in!
== match == This function returns a substring from the source string that matches a specified pattern. Usage: : <code><nowiki>{{#invoke:</nowiki>String|match|''source_string''|''pattern_string''|''start_index''|''match_number''|''plain_flag''|''nomatch_output''}}</code> OR : <code><nowiki>{{#invoke:</nowiki>String|match|s= ''source_string'' |pattern= ''pattern_string'' |start= ''start_index'' |match= ''match_number'' |plain= ''plain_flag'' |nomatch= ''nomatch_output'' }}</code> Parameters: ; s : The string to search ; pattern : The pattern or string to find within the string ; start : The index within the source string to start the search. The first character of the string has index 1. Defaults to 1. ; match : In some cases it may be possible to make multiple matches on a single string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1. ; plain : Boolean flag indicating that pattern should be understood as plain text and not as a [[mw:Extension:Scribunto/Lua reference manual#Ustring patterns|Scribunto ustring pattern]] (a unicode-friendly [[w:Lua (programming language)|Lua]]-style [[w:regular expression|regular expression]]). Defaults to false (to change: <code>plain=true</code>) ; nomatch : If no match is found, output the "nomatch" value rather than an error. ; ignore_errors : If no match is found and ignore_errors=true, output an empty string rather than an error. If the match_number or start_index are out of range for the string being queried, then this function generates an error. An error is also generated if no match is found. If one adds the parameter ignore_errors=true, then the error will be suppressed and an empty string will be returned on any failure. For information on constructing [[w:Lua (programming language)|Lua]] patterns, a form of [[w:regular expression|regular expression]], see: * [[mw:Special:MyLanguage/Extension:Scribunto/Lua reference manual#Patterns|Scribunto patterns]] * [[mw:Special:MyLanguage/Extension:Scribunto/Lua reference manual#Ustring patterns|Scribunto Unicode string patterns]] Examples: * <code><nowiki>{{#invoke:String|match| abc123def456 |%d+}}</nowiki></code> β {{#invoke:String|match| abc123def456 |%d+}} * <code><nowiki>{{#invoke:String|match|s= abc123def456 |pattern= %d+ }}</nowiki></code> β {{#invoke:String|match|s= abc123def456 |pattern= %d+ }} * <code><nowiki>{{#invoke:String|match| abc123def456 |%d+|6}}</nowiki></code> β {{#invoke:String|match| abc123def456 |%d+|6}} * <code><nowiki>{{#invoke:String|match|s= abc123def456 |pattern= %d+ |start= 6 }}</nowiki></code> β {{#invoke:String|match|s= abc123def456 |pattern= %d+ |start= 6 }} * <code><nowiki>{{#invoke:String|match|s= abc123def456 |pattern= %d+ |start= 6 |match= 2 }}</nowiki></code> β {{#invoke:String|match|s= abc123def456 |pattern= %d+ |start= 6 |match= 2 }} * <code><nowiki>{{#invoke:String|match|s= abc123%d+ |pattern= %d+ }}</nowiki></code> β {{#invoke:String|match|s= abc123%d+ |pattern= %d+ }} * <code><nowiki>{{#invoke:String|match|s= abc123%d+ |pattern= %d+ |plain= true }}</nowiki></code> β {{#invoke:String|match|s= abc123%d+ |pattern= %d+ |plain= true }} * <code><nowiki>{{#invoke:String|match|s= abc |pattern= %d }}</nowiki></code> β {{#invoke:String|match|s= abc |pattern= %d |no_category=true}} * <code><nowiki>{{#invoke:String|match|s= abc |pattern= %d |nomatch= No numeric characters in string }}</nowiki></code> β {{#invoke:String|match|s= abc |pattern= %d |nomatch= No numeric characters in string }} * <code><nowiki>{{#invoke:String|match|s= abc |pattern= %d |ignore_errors= true }}</nowiki></code> β {{#invoke:String|match|s= abc |pattern= %d |ignore_errors= true }} * <code><nowiki>{{#invoke:String|match|s= 0012001200 |pattern= 0*(%d*) }}</nowiki></code> β {{#invoke:String|match|s= 0012001200 |pattern= 0*(%d*) }}
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)