string - 处理字符串的 Google 电子表格脚本

标签 string google-apps-script google-sheets

我有一个关于如何在 Google Script 中使用“字符串”类型的问题?

我有一个包含不同格式站点的专栏,例如
http:// /testsite.com/, http:// /www.sitetest.net/, dot.anothersite.com, http:// /anysite.net/index.html
等等。

所以我想将这些记录自动格式化为一个模板:sitename.domain(例如 http:///testsite.com/=testsite.com||http:///www。 sitetest.net/= sitetest.net)

我通过这个脚本得到这个信息:

var sheet = SpreadsheetApp.getActiveSheet();
  var sheetName = sheet.getName();
  var restrictSheet = "Summary";
  if (sheetName != restrictSheet){ // I don't need to modify first sheet from my spreadsheet
    var sheetRange = sheet.getActiveRange();
    var sData = sheet.getRange("A3:A"); // column with sites
    var TextArray = sData.getValues();
  }else Browser.msgBox("wrong sheet");
}

而且我不知道如何在 google 脚本中使用字符串。例如,在 C++ 中,我可以使用字符串函数,如 String.Find() 或 String.Mid()。但是我在 Google Scripts 中看不到相同的功能

最佳答案

嗯......我在我自己的问题上找到了答案:D

Google Script 使用 JavaScript 中的 String 类
所以来自 JS 的函数和方法也适用于 Google Scripts..

http://www.w3schools.com/jsref/jsref_obj_string.asp

可能它会帮助某人。

关于string - 处理字符串的 Google 电子表格脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15071717/

相关文章:

javascript - 如何在 Google 文档中创建宏

google-sheets - 相等列值的数量求和公式

google-sheets - 如何删除 Google 表格中选定单元格上的网格线?

google-apps-script - Google 表格中的条件格式 : Can I use custom function in the 'custom formula is:' field?

python - 如何将字符添加到 pandas 列中的日期或 str?

google-apps-script - 是否可以在 HTMLService 中使用 localStorage?

Ruby 字符串可变性

google-apps-script - 提交表单时使用表单响应在云端硬盘中创建文件夹

javascript - 在替换之前获取子字符串的位置

c++ - 无法理解 C 中字符串和循环的这种意外行为