跳至內容

模板:Replace

輕之舟百科,讓知識輕裝啟航

{{{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。(編輯 | 歷史)
編者可以在本模板的沙盒(創建 | 鏡像)和測試樣例(創建)頁面進行實驗。
請將模板自身所屬的分類添加在文檔中。本模板的子頁面。