如果可能,我想对我的自定义函数使用arrayformula,因为我想输入一个值范围
我也收到此错误:TypeError: Cannot read property "0" from null.
另外,这个:Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls
var regExp = new RegExp("Item: ([^:]+)(?=\n)");
var matches=new regExp(input);
return matches[0];
}
非常感谢一些帮助
编辑:
根据第二张图片,我还尝试使用此正则表达式公式查找以“帐单地址”开头的单词
但是对于第一张图片,我使用了正则表达式来查找以“Item”开头的单词
对于两个自定义功能,该错误看起来都是相同的。
最佳答案
如果要使用custom function
查找所有以Item
或item
开头的字符串,并从查找后提取内容,则可以使用下面提供的代码。通过使用match()
函数检查正则表达式,并返回所需结果;否则,它将返回null
。
function ITEM(input) {
var regEx = /(?:I|i)tem\s*(.*)$/;
var matches = input.match(regEx);
if (matches && matches.length > 1) {
return matches[1];
} else {
return null;
}
}
如果要像在共享代码中一样使用
RegExp
,则应使用\\
而不是\
。要检查和验证
regular expressions
,可以使用this site。您收到的
Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls.
错误消息是由于您试图在太多单元格上调用自定义函数而导致的-例如一次在太多单元格上拖动自定义函数。您可以检查有关此错误消息here的更多信息。
关于regex - 计算用户自定义功能Google Apps脚本输入的值的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59624043/