【发布时间】: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
我在 Google 表格中有一列电子邮件地址,我想删除所有域名和“@”符号并将其复制到新列中。例如:
将域复制并删除到:
【问题讨论】:
标签: regex google-sheets google-sheets-formula trim array-formulas
在谷歌应用脚本上使用这个函数:
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]);
})
}
【讨论】: