google-sheets - 在 Google 表格中多次丢弃两个特定单词之间的所有文本

标签 google-sheets

我在 A1 中有一些数据,我想去掉两个特定单词之间出现的一些文本 block 。

文本来自一些 json 数据,因此它是文本、数字和特殊字符的混合。但就我而言,一旦识别了这两个单词,就可以删除这些单词之间的所有内容,而不指定任何选择。

我尝试过的方法。

我用两个不同的分隔符替换了这两个单词,然后应用了 SUBSTITUTE、SEARCH 和 MID 函数,但不起作用。

在我看来,这个公式相当大而且不整洁,可能有更好的方法来做到这一点。

链接

https://docs.google.com/spreadsheets/d/10MpkGPzFyCPSZi7-qr7Ovi9vYevnaAVAn_rG0fsCrxU/edit?usp=sharing

最佳答案

使用文件内定义的 xpath

function getDataJSON(input,xpath){
  var data = JSON.parse(input)
  var liste = xpath.join().split(",")
  var result = []
  liste.forEach(function(elem){
    try{
      result.push(eval('data[0]'+elem.replace(/\//g,'\.')))
    }
    catch(e){result.push('')}
  })
  return([result])
}

enter image description here

关于google-sheets - 在 Google 表格中多次丢弃两个特定单词之间的所有文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69163131/

相关文章:

google-sheets - 将 Rows 函数与不返回任何内容的查询一起使用时出错

database - 谷歌应用程序脚本 : How to copy and automatically edit the data from a spreadsheet to others?

javascript - 谷歌应用脚​​本: Parsing XML results in error: "Cannot find function getChildren in object"

button - 我需要一个按钮来清除 Google 电子表格中的单元格

google-sheets - 突出显示工作表中的第二个实例重复项

android - 在 Android 上使用谷歌电子表格

google-apps-script - Google 表格脚本在共享链接中不起作用

google-apps-script - 当事件电子表格更改时调用事件

javascript - 尝试使用 Google 脚本从 Google 表格中获取数据并显示在具有水平标签的网页上

javascript - 语法错误: Unexpected identifier while Parsin XML Data Using Google App Script