Template:Replace
(Redirected from Template:Str replace)
{{{1}}}
This template was originally from Template:Replace in Chinese Wikipedia, used here under CC BY-SA 3.0; the names of contributors can be found here.
Parameters and usage
{{replace|string|replace|replace with|count=time to replace}}
Provide the string to parameter 1
, and every instance of the parameter 2
will be replaced by on instance of the parameter 3
. These parameters are all sensitive to spaces.
You may limit how many times replacements are performed with the parameter count
. If count
is not provided, the template will replace very instance found.
Example
{{replace|One two two three two four twotwo five|two|@}}
→ One @ @ three @ four @@ five{{replace|One two two three two four twotwo five|two|@|count=2}}
→ One @ @ three two four twotwo five- To remove something, replace with with empty string:
{{replace|One two two three two four twotwo five|two|}}
→ One three four five
space sensitivity
{{replace|One-two two-three two-four twotwo-five space- six|-|@}}
→ One@two two@three two@four twotwo@five space@ six{{replace|One-two two-three two-four twotwo-five space- six|- |@}}
→ One-two two-three two-four twotwo-five space@six