ވިކިޕީޑިއާ، މިނިވަން އެކުމާފާނުން
0
| This template uses Lua:
|
This is the
{{str len}} meta-template.
It takes a string as parameter and returns its length (excluding spaces at the start and end). It can now count as high as necessary.
If the parameter is empty or undefined it is considered to be of zero length:
{{str len}}
returns 0
{{str len|}}
returns 0
{{str len| }}
returns 0
It counts the length correctly, even if the string contains spaces, looks like a number, or contains special characters:
{{str len| ab cde }}
returns 6
{{str len| 1234567 }}
returns 7
{{str len| café åäö }}
returns 8
{{str len| ފަންވަތް:Tlp }}
returns 500
{{str len| ފަންވަތް:Tlp }}
returns 1500
Template parameters[Edit template data]
Parameter | Description | Type | Status |
---|
Alpha-numeric text | 1 | The string to be counted
| String | required |
---|
This is the first general-purpose template to be implemented using mw:Extension:Scribunto. The Lua code is located in Module:String.
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 |
---|
|
|
|