Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GoogleSheets函数将字符串转换为可读的URL_Url_Google Sheets - Fatal编程技术网

GoogleSheets函数将字符串转换为可读的URL

GoogleSheets函数将字符串转换为可读的URL,url,google-sheets,Url,Google Sheets,我搜索google sheets函数,将字符串转换为可读的URL 字符串: “死亡是德国的一根弦,是沙芬和勒斯蒂根·布卢登·乌姆劳滕的弦” 网址: “死亡是德国的一根弦,它是沙芬ss和莱斯提根bloeden umlauten” Äto ae Üto ue Öto oe äto ae 吕托 奥托伊 ß至ss “空间”到- 创建此自定义函数 function multipass(text, ChangeFrom, ChangeTo) { ChangeFrom = ChangeFrom.map

我搜索google sheets函数,将字符串转换为可读的URL

字符串: “死亡是德国的一根弦,是沙芬和勒斯蒂根·布卢登·乌姆劳滕的弦”

网址: “死亡是德国的一根弦,它是沙芬ss和莱斯提根bloeden umlauten”

  • Äto ae
  • Üto ue
  • Öto oe
  • äto ae
  • 吕托
  • 奥托伊
  • ß至ss
  • “空间”到-

创建此自定义函数

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;由安斯特鲁瑟的诺曼提供

我的最终答案是:
=lower(多路径(B1、D2:D9、E2:E9))
多路径
(进行多次转换)和
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();
}


对于数组,请执行以下操作:

=ARRAYFORMULA(IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A2:A), 
 "ä", "ae"), 
 "ü", "ue"),
 "ö", "oe"),
 "ß", "ss"), 
 " ", "-")))

如果有人正在寻找将通用编码url转换为可读url的公式 e、 g.
是%20you%20a%20planner%20or%20spontaneous%3F
-->
是-you-a-planner-or-automative

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", "")

谢谢你的快速回复。是否还有一种在函数中设置翻译表的方法?而不是在工作表中的表格中?@n8lauscher修改了代码,将“翻译表”作为函数的一部分。代码可能看起来既长又复杂,但我在中留下了一堆
Logger
语句来帮助理解每个阶段发生的事情。事实上,除了“翻译表”之外,代码只有四(4)行。您需要添加
lower
,以去掉“幸存”的大写字母;例如“Umlauten”中的“U”
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", "")