Template:Str rep
Usage
{{Str rep |1= |2= |3= }}
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
1source | Source string | The text to replace in | empty | required |
2pattern | Pattern search | The text to search for | empty | required |
3replace | Replacement string | The text to replace with | empty | suggested |
4count | Replace count | The number of replacements to perform on the source string. Set |4=all to replace all instances of the pattern string. | 1 | optional |
5plain | Replacement type | By default, the replacement type parses the pattern search and replacement string as plain strings. To use regular expression replacements, set |5=false | true | optional |
|
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard. Existing template documentation Newly created template documentation and imports Wikipedia's help about TemplateData • Commons-specific information Returns a replacement string with the first occurrence (by default) of a source string replaced with a pattern string. Note that while the first two parameters are marked required, the template technically works even without supplying them, but simply returns string0 in this case.
| ||||||||||||||||||||||||||||||
Additional information
The template is intended to be used in the following namespaces: the Template namespace
The template is intended to be used by the following user groups: all users
Relies on:
Module:String
Example
{{Str rep|032|3|1}}
renders as:
012
See also
Trimming templates:
- {{Trunc}} – To trim down to a specified number of characters.
- {{Trim}} — To trim any leading or trailing whitespace.
- {{Str left}} – To trim down to a specified number of characters, or duplicate the string to a specified number.
- {{Str right}}
- {{Strip}} – To strip (remove) a given number of characters from the beginning/end of the string
Analyzing templates:
- {{Str endswith}} – To check if a string ends with a given string.
- {{Str find}} – Returns the numerical location of a given string in a string, up to 50 characters.
- {{Str len}} – Returns a string's length. Can count up to 500 characters.
String length comparison templates:
- {{Str ≤ len}} – To check if a string is "shorter or equally long" or "longer" than a given length.
Technical stuff:
- mw:Help:Magic words – About
{{padleft:|}}. - mw:Help:Extension:ParserFunctions – About
{{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}},etc. - Module:String - Script with native string parsing
Localization
This template is not intended to be localized.
Category:Templates not requiring internationalizationCategory:String manipulation templates