2026/4/18小於 1 分鐘
replaceInFile
在檔案中替換內容。
語法
replaceInFile(path: string, search: string, replace: string): void參數
| 參數名稱 | 類型 | 說明 |
|---|---|---|
path | string | 要修改的檔案路徑 |
search | string | 要搜索的內容 |
replace | string | 用於替換的內容 |
// 這將在 file.txt 中將 "old content" 替換為 "new content"
FilesJS.replaceInFile('file.txt', 'old content', 'new content');