我搜索google-sheets函数以将字符串转换为可读的URL
字符串: “在德意志联邦理工大学教养院就读,死于乌姆劳滕”
url: “死于德国人的爱因斯坦琴弦上的德国弦-scharfen-ss和laestigen-bloeden-umlauten”
答案 0 :(得分:1)
创建此自定义函数
function multipass(text, ChangeFrom, ChangeTo) {
ChangeFrom = ChangeFrom.map (String);
var re = new RegExp(ChangeFrom.join('|'), 'g');
return text.replace(re, function (match) {return
ChangeTo[ChangeFrom.indexOf(match)];});
}
从WebApps Multiple substitutions in a single text;由Anstruther的Norman提供。
我的最终答案:
=lower(multipass(B1,D2:D9,E2:E9))
是multipass
(以进行多次转换)和lower
(以将任何剩余的大写字母减小为小写)的组合。
修订版-在函数中查找并替换值
function fandr(text) {
// add key:value pairs to the "find_replace" variable
var find_replace = {
'Ä': 'ae',
'Ü': 'ue',
'Ö': 'oe',
'ä': 'ae',
'ü': 'ue',
'ö': 'oe',
'ß': 'ss',
' ': '-'
};
// loop through the keys and replace with the value
Object.keys(find_replace).map(function(find) {
var replace = find_replace[find];
// Logger.log("DEBUG: find key: "+find+", replace value: "+replace);//DEBUG
// note the "g" - this is to replace all the matches for the given key/value pair
text = text.replace(find, replace, "g");
//Logger.log("DEBUG: modified text = "+text);//DEBUG
});
//Logger.log("DEBUG: Final modified text = "+text.toLowerCase());//DEBUG
return text.toLowerCase();
}
答案 1 :(得分:1)
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A2),
"ä", "ae"),
"ü", "ue"),
"ö", "oe"),
"ß", "ss"),
" ", "-")
对于数组,请执行以下操作:
=ARRAYFORMULA(IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A2:A),
"ä", "ae"),
"ü", "ue"),
"ö", "oe"),
"ß", "ss"),
" ", "-")))
答案 2 :(得分:1)
如果有人正在寻找将通用编码 url 转换为可读 url 的公式
例如are%20you%20a%20planner%20or%20spontaneous%3F
--> are-you-a-planner-or-spontaneous
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2, "%20", "-"), "%3F", ""), "%2C", ""), "%9D", ""), "%28a", ""), "%21", ""), "%E2", ""), "%29", ""), "%80", ""), "%99", ""), "%2F", ""), "%9C", ""), "%27s", ""), "%5B", "")