You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google AppScript提取Zelle付款记录中的收款人名称?

解决Zelle付款记录收款人名称提取问题

原代码失效的核心原因是关键词大小写不匹配或输入文本格式变动,导致找不到大写的FROM,进而错误截取了前缀内容。以下是两种可靠修复方案:

方案1:兼容大小写调整原逻辑

通过统一匹配规则找到关键词位置,同时增加异常处理避免报错:

function extractBusinessName(input) {
  var words = input.split(' ');
  // 不区分大小写查找"from"的位置
  var fromIndex = words.findIndex(word => word.toLowerCase() === 'from');
  if (fromIndex === -1) return ''; // 处理无关键词的情况
  // 提取"from"之后的所有内容作为收款人名称
  var businessName = words.slice(fromIndex + 1);
  return businessName.join(' ');
}

方案2:用正则表达式适配更灵活的格式

正则能直接精准匹配目标内容,适配不同的文本排版:

function extractBusinessName(input) {
  // 匹配"from"(不区分大小写)之后的所有字符,自动忽略前后空格
  const match = input.match(/from\s+(.*)/i);
  return match ? match[1].trim() : '';
}

测试示例:若输入为Zelle payment from BOBAME LLC,两种方案都会返回BOBAME LLC。

内容的提问来源于stack exchange,提问作者Testing Testing

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 22:04:54