您好我正在嘗試編寫一個谷歌電子表格自定義函數。它收到一個範圍並吐出乾淨的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
不,用===它會檢查輸入是否爲空。你在做什麼是做你不想要的輸入。 –