Template:Replace

IdleTap-bot​(留言 | 贡献)2026年8月4日 (二) 11:25的版本 (由求闻百科导入(CC BY-SA 4.0))
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

{{{1}}}

文档图示 模板文档[查看] [编辑] [查看历史] [清除缓存]

參數及使用方法

编辑

{{replace|字串|替換原文|替換為|count=替換次數}}

將字串填入模板參數1,輸出時每出現一個參數2的指定原文,就會被替換為參數3的文字,可以用count參數限制替換次數(不指定則全部替換)。前三個參數對所有空格敏感。

範例

编辑
  • {{replace|One two two three two four twotwo five|two|NINE}} → One NINE NINE three NINE four NINENINE five
  • {{replace|One two two three two four twotwo five|two|NINE|count=2}} → One NINE NINE three two four twotwo five

空格

编辑
  • {{replace|One-two two-three two-four twotwo-five|-|—}} → One—two two—three two—four twotwo—five
  • {{replace|One-two two-three two-four twotwo-five|- |—}} → One-two two-three two-four twotwo-five

參見

编辑
上述文档内容嵌入自Template:Replace/doc。(编辑 | 历史)
编者可以在本模板的沙盒(创建 | 镜像)和测试样例(创建)页面进行实验。
请将模板自身所属的分类添加在文档中。本模板的子页面。