从Google表格中删除字符,直到@符号

问题描述 投票:0回答:3

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

将域复制并删除到:

  • B列
  • 测试
  • testb
  • testc
regex google-sheets google-sheets-formula trim array-formulas
3个回答
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]);
})
}

0
投票

您需要的是:

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

enter image description here


0
投票

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

enter image description here

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

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.