Changes

Jump to navigation Jump to search
1,734 bytes added ,  19:54, 8 November 2019
m
remove blank line
{{Documentation subpage}}
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
{<nowiki />{replace |''string'' |''target'' |''replacement'' [|count=''n'']}<nowiki />}

Returns ''string'' with the first ''n'' occurrences of ''target'' replaced with ''replacement''. Omitting <code>count</code> will replace all occurrences.

===Examples===
* <code><nowiki>{{replace |One two two three two four twotwo five |two |NINE}}</nowiki></code> &rarr; {{replace|One two two three two four twotwo five|two|NINE}}
* <code><nowiki>{{replace |One two two three two four twotwo five |two |NINE |count=2}}</nowiki></code> &rarr; {{replace|One two two three two four twotwo five|two|NINE|count=2}}

=== TemplateData ===
<templatedata>
{
"description": "This template replaces a substring in a string with a given replacement.",
"format": "inline",
"params": {
"1": {
"label": "source string",
"description": "The string to replace in",
"required": true
},
"2": {
"label": "pattern",
"description": "The string or Lua ustring pattern to search for",
"required": true
},
"3": {
"label": "replacement",
"description": "The replacement text",
"required": true
},
"count": {
"label": "count",
"description": "The number of occurrences to replace; defaults to all",
"type": "number"
},
"regex": {
"label": "regex",
"description": "Whether the pattern is a Lua ustring pattern (no means search for literally that character sequence)",
"example": "yes",
"type": "boolean",
"default": "no"
}
}
}
</templatedata>
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Templates]]
}}</includeonly>
Anonymous user

Navigation menu