使用 TextFinder 和 Apps 脚本在 Google 个工作表中查找和替换文本
Find and replace text in Google Sheets using TextFinder and Apps Script
我有一个代码,我希望代码在活动 sheet 中找到符号 " 并将其替换为 space 。我已经测试了这个文本示例 - Tot 和代码工作正常。有没有一种方法可以使用代码,用 space 和 运行 替换符号 "。正在使用的代码下方:
function searchAndReplace(searchTerm, replacement)
{textFinder = SpreadsheetApp.getActive().getSheetByName("Sheet1")
.createTextFinder("Tot")
.matchEntireCell(真)
.matchCase(真)
.matchFormulaText(假)
.ignoreDiacritics(假)
.replaceAllWith(" ");
}
尝试
function searchAndReplace() {
textFinder = SpreadsheetApp.getActive().getSheetByName("Sheet1")
.createTextFinder("\"")
.matchEntireCell(false)
.matchCase(true)
.matchFormulaText(false)
.ignoreDiacritics(false)
.replaceAllWith(" ");
}
在这种情况下可以缩短为:
function searchAndReplace() {
SpreadsheetApp.getActive().getSheetByName('Sheet1').createTextFinder('"').replaceAllWith(' ');
}
我有一个代码,我希望代码在活动 sheet 中找到符号 " 并将其替换为 space 。我已经测试了这个文本示例 - Tot 和代码工作正常。有没有一种方法可以使用代码,用 space 和 运行 替换符号 "。正在使用的代码下方:
function searchAndReplace(searchTerm, replacement)
{textFinder = SpreadsheetApp.getActive().getSheetByName("Sheet1")
.createTextFinder("Tot")
.matchEntireCell(真)
.matchCase(真)
.matchFormulaText(假)
.ignoreDiacritics(假)
.replaceAllWith(" "); }
尝试
function searchAndReplace() {
textFinder = SpreadsheetApp.getActive().getSheetByName("Sheet1")
.createTextFinder("\"")
.matchEntireCell(false)
.matchCase(true)
.matchFormulaText(false)
.ignoreDiacritics(false)
.replaceAllWith(" ");
}
在这种情况下可以缩短为:
function searchAndReplace() {
SpreadsheetApp.getActive().getSheetByName('Sheet1').createTextFinder('"').replaceAllWith(' ');
}