google-apps-script - 您如何使用应用脚本查找和替换字符?
问题描述
我想在名为“SF”的特定 Google 工作表中找到此字符 (’) 的每个实例,并将其从工作表中删除。
到目前为止,我有能力将其从该表中的特定范围(即 J:J)中删除,但希望该范围为(A:AT)
请告知我的功能在处理范围时哪里出错。
function CleanInputs() {
var sf = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SF");
var range = sf.getRange("J:J");
//Finds and replace character encoding issues from Screamingfrog
range.setValues(range.getValues().map(function(row) {
return [row[0].replace(/’/, "")];
}));
}
解决方案
function myFunction() {
const sheetName = "SF";
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sh = ss.getSheetByName(sheetName);
sh.createTextFinder("’").replaceAllWith("");
}
推荐阅读
- xml - 如何在 XML 文件中使用 Kotlin 方法?
- javascript - 如何将变量作为href和变量文本放入其中?(谷歌地图信息窗口)
- java - AWS Cloud9 Gradle 集成
- types - 类型的值不能分配给类型\的实体
- sql - sql查找所有上车的乘客
- javascript - 画布RGBA到RGB转换
- python - 如何遍历对象列表并获取特定属性?
- python - 我正在尝试从基于另一个列表(在循环内)的重复列表中删除项目。错误:列表索引超出范围
- javascript - 我们如何在 Firestore 中将数据从一个集合复制到另一个集合
- rust - Substrate Rust - 未解决的导入 node_template_runtime