【问题标题】:Remove Characters from Google Sheets up to @ sign从 Google 表格中删除字符直到 @ 符号
【发布时间】:2019-10-30 15:01:11
【问题描述】:

我在 Google 表格中有一列电子邮件地址,我想删除所有域名和“@”符号并将其复制到新列中。例如:

  • A 列
  • test@test.com
  • testb@gmail.com
  • testc@yahoo.com

将域复制并删除到:

  • B 列
  • 测试
  • 测试b
  • 测试c

【问题讨论】:

    标签: regex google-sheets google-sheets-formula trim array-formulas


    【解决方案1】:

    在谷歌应用脚​​本上使用这个函数:

    function myFunction() {
    // Your spreadsheet
    var ss = SpreadsheetApp.getActive()
    //if you got only one sheet
    var sheet = ss.getSheets()[0];
    // This is in the case that your sheet as a header, if not replace 2 by 1 and (sheet.getLastRow()-1) by sheet.getLastRow()
    var valuesColumnA = sheet.getRange(2,1,(sheet.getLastRow()-1)).getValues();
    //Just to have each value in the same array
    var valuesColumnAMapped = valuesColumnA.map(function(r){return r[0]});
    
    valuesColumnAMapped.forEach(function(value, index){
    var split = value.split("@");
    sheet.getRange((index+2),2).setValue(split[0]);
    })
    }
    

    【讨论】:

      【解决方案2】:

      您只需要:

      =ARRAYFORMULA(IFNA(REGEXEXTRACT(A1:A&"", "(.+)@")))
      

      【讨论】:

        【解决方案3】:

        根据我的理解,我的回答可能是我错的,所以如果我理解正确,请关注。 使用 split 得到这个

        转到数据 单击将文本拆分为列 从下拉菜单中选择自定义 输入 @ 即可得到结果。

        【讨论】:

          猜你喜欢
          • 2021-12-03
          • 2020-11-17
          • 1970-01-01
          • 1970-01-01
          • 2017-03-19
          • 1970-01-01
          • 1970-01-01
          • 2016-11-22
          • 2015-03-17
          相关资源
          最近更新 更多