从Google表格中删除字符(最多@符号)

时间:2019-10-30 15:01:11

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

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

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

将域复制并删除到:

  • B列
  • 测试
  • testb
  • testc

3 个答案:

答案 0 :(得分:0)

根据我的理解,我的回答可能是我错了,所以如果我理解正确,请按照以下说明进行操作。 使用split来获取

enter image description here

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

enter image description here

答案 1 :(得分:0)

在Google App脚本上使用此功能:

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 :(得分:0)

您需要的是:

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

enter image description here