| This template uses Lua:
|
This template wraps the function ފަންވަތް:Mlx, and provides the extra option to return an alternative string (including a blank string) when nothing is found.
{{In string|source_string|target_string|start_index|plain_flag|nomatch_returntext}}
- or
{{In string|source=source_string |target=target_string |start=start_index |plain=plain_flag |nomatch=nomatch_returntext}}
{{In_string
|source=
|target=
|start=
|plain=
|nomatch=
}}
- By default, when the target is not found,
0
is returned.
- Set
|nomatch=anytext
to replace that 0
. Also, |nomatch=
<blank> returns blank not 0.
- Note: outer spaces are not conserved.
- Using the nomatch option
- {{#if:{{in string|source=pancake|target=pizza|plain=true|nomatch=}}|Is a pizza|Not a pizza}} → Not a pizza
- {{#if:{{in string|source=Hawaiian pizza|target=pizza|plain=true|nomatch=}}|Is a pizza|Not a pizza}} → Is a pizza
{{In string|abc123def }}
→ 0
{{In string|source= abc123def }}
→ 0
{{In string|abc123def |123}}
→ 4
{{In string|source= abc123def |target= 123 }}
→ 4
{{In string|abc123def |%d|3|false}}
→ 4
{{In string|source= abc123def |target= %d |start= 3 |plain= false }}
→ 4
- nomatch=xxx
{{In string|abc123def |nomatch=xxx}}
→ xxx
{{In string|source= abc123def |nomatch=xxx}}
→ xxx
{{In string|abc123def |123|nomatch=xxx}}
→ 4
{{In string|source= abc123def |target= 123 |nomatch=xxx}}
→ 4
{{In string|abc123def |%d|3|false|nomatch=xxx}}
→ 4
{{In string|source= abc123def |target= %d |start= 3 |plain= false |nomatch=xxx}}
→ 4
- nomatch = blank
{{In string|abc123def |nomatch=}}
→
{{In string|source= abc123def |nomatch=}}
→
{{In string|abc123def |123|nomatch=}}
→ 4
{{In string|source= abc123def |target= 123 |nomatch=}}
→ 4
{{In string|abc123def |%d|3|false|nomatch=}}
→ 4
{{In string|source= abc123def |target= %d |start= 3 |plain= false |nomatch=}}
→ 4
- module Examples
{{#invoke:String|find|abc123def }}
→ 0
{{#invoke:String|find|source= abc123def }}
→ 0
{{#invoke:String|find|abc123def |123}}
→ 4
{{#invoke:String|find|source= abc123def |target= 123 }}
→ 4
{{#invoke:String|find|abc123def |%d|3|false}}
→ 4
{{#invoke:String|find|source= abc123def |target= %d |start= 3 |plain= false }}
→ 4
ފަންވަތް:Template data header
Template data
|
Template parameters Parameter | Description | Type | Status |
---|
1 | 1 | no description
| Unknown | optional |
---|
2 | 2 | no description
| Unknown | optional |
---|
3 | 3 | no description
| Unknown | optional |
---|
4 | 4 | no description
| Unknown | optional |
---|
source | source | no description
| Unknown | optional |
---|
target | target | no description
| Unknown | optional |
---|
start | start | no description
| Unknown | optional |
---|
plain | plain | no description
| Unknown | optional |
---|
nomatch | nomatch | no description
| Unknown | optional |
---|
|
String-handling templates (help page) |
---|
Substring (select chunk of string by its position) |
---|
| Select a substring based on starting and ending index counted in either direction.
| | Keep the first N characters of a string, or duplicate it to N characters.
| | Return all but the last N characters of a string.
| | Return the N-th character of a string.
|
| | Return substring starting at N-th character to end of string.
| | Return the last N characters of a string; or a given value if empty.
| | Return substring of given length starting at N-th character.
| |
|
|
Trimming (select/remove chunk of string by character type) |
---|
| Trim any leading or trailing whitespace
| | Trim down to the beginning letters.
| | Trim down to the beginning numbers.
| | Trim any leading or trailing square brackets.
| | Trim leading or trailing matching quotes.
| | Trim up to six instances of specified <prefix>.
|
| | Extract a short string from a long string.
| | Trim down to the first space.
| | Remove anything before the first space.
| | Trim down from the last space.
| | Remove anything after the last space.
| |
|
|
Select/remove specific item from string |
---|
| Removes wikilink brackets (wikicode); all or outer only.
| | Removes wikicode (formatting and brackets)
| | Trim off any parenthesis text at the end of a string (disambiguation).
| | Returns text in parentheses at the end of a string (disambiguation).
|
| | Returns the 3-or-4-digit year from a pagename, if any.
| | Returns the 4-digit decade from a pagename (e.g. "1740" from "Foo 1740s bar"), if any.
| | Returns any number from a pagename.
| | Removes "WikiProject" from a pagename.
| |
|
|
Insertion, replacement and length |
---|
| Repeat character string a specified number of times.
| | Returns the string, after replacing all occurrences of a specified string with another string.
| | Returns the string, after replacing the first occurrence of a specified string with another string.
| | Returns the string, after removing all characters that are not digits 0–9
| | Displays wikitext as plain text.
|
|
| Returns a string's length.
| | Check if a string is "longer or equally long" or "shorter" than a given length.
| | Check if a string is "shorter or equally long" or "longer" than a given length.
| | Check if a string is "not equal" or "equal" to a given length.
| |
|
|
Analysis and searching |
---|
| Check if a string starts or ends with a given string.
| | Returns the numerical location of a given string in a string.
| | Count the number of occurrences of a pattern within a string.
| | Match one or multiple patterns with a variety of possible outputs.
|
|
| Array item manipulation and retrieval.
| | Takes a noun and produces the appropriate indefinite article, based on whether the first letter is a vowel.
| | Returns optional string when given string is not found
| | Returns number when true, blank when not numeric.
| | Returns the number of letters that begin a string.
| | Returns the number of numbers that begin a string.
| |
|
|
Modules and built-in functions |
---|
|
|
|