您好我正在尝试编写一个谷歌电子表格自定义函数。它收到一个范围并吐出干净的rootdomain。我只是遇到了“太多的处决” - 我必须在整张表格上运行它。所以我增加了一个范围。谷歌电子表格自定义功能代码不工作:= RootDomain
现在反馈是“内部错误功能” ......
帮助表示赞赏....这必须是可能的!
/**
* Generates clean root domains
*
* @param {input} input The value to change to a root domain.
* @return The clean root domain.
* @RootDomain
*/
function RootDomain(input) {
if (input == null) return '';
if (input.map) { // Test whether input is an array.
return input.map(RootDomain); // Recurse over array if so.
} else {
if (input = '') return '';
regex = new RegExp(/((www)\.)?.*(\w+)\.([\w\.]{2,6})/);
return regex.exec(input)[0].replace(/^http(s)?:\/\//i, "").replace(/^www\./i, "").replace(/\/.*$/, "");
}
}
变化**如果(输入= '')返回 ''; **的**,如果(输入=== '')返回 ''; * *。当您仅使用一个'='号时,您正在将**输入**设置为空 –
THX!问题是,有三个===它比较字符串,但如果INPUT为空(当没有输入或单元格为空时)会发生什么 – SNH
不,用===它会检查输入是否为空。你在做什么是做你不想要的输入。 –