Template:String replace
{{{1}}}
This documentation is transcluded from Template:String replace/doc.
Returns string with the first n occurrences of target replaced with replacement. Omitting count
will replace all occurrences. Space counts as a character if placed in any of the first three parameters
Usage
{{String replace |1= |2= |3= |count= }}
{{strrep|string|target|replacement[|count=n]}}
Template parameters
Parameter | Description | Default | Status | |
---|---|---|---|---|
1 | string | Input string | empty | required |
2 | target | substring to find | empty | required |
3 | replacement | text to replace target string with | empty | optional |
count | count | if specified, how many occurrences of target to replace with with replacement | empty | optional |
Additional information
The template is intended to be used in the following namespaces: all namespaces
The template is intended to be used by the following user groups: all users
Relies on:
Module:String
Example
{{String replace|One two two three twotwo four two five|two|NINE|count=4}}
renders as:
One NINE NINE three NINENINE four two five
Examples
{{String replace|123456789|2|0}}
→ 103456789{{String replace|\d\d\d\d \d\d\d\d \d\d\d\d \d\d\d[\dX]|\|%}}
→ %d%d%d%d %d%d%d%d %d%d%d%d %d%d%d[%dX]