【问题标题】:Regexp to translate Google search words with accent marks正则表达式翻译带有重音符号的谷歌搜索词
【发布时间】:2011-08-29 16:20:21
【问题描述】:

我正在使用一些代码从 Google 网址中提取搜索关键字。感谢对我之前帖子 (Extract keyword from Google search in Javascript) 的回答,我能够做到这一点。

但我意识到使用重音符号的单词会给我带来麻烦(例如,“chaîne”(法语单词)被翻译为“cha%C3%AEne”)。 有人有同样的问题并写了一些神奇的正则表达式吗? :-)

布鲁诺

【问题讨论】:

    标签: javascript regex url google-chrome search-engine


    【解决方案1】:

    只需使用 decodeURI

    decodeURI("cha%C3%AEne");
    

    【讨论】:

      【解决方案2】:

      您可能想要解码字符串。使用

      decodeURIComponent("cha%C3%AEne");
      

      herehere

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-21
        • 1970-01-01
        • 2017-06-15
        • 2011-10-13
        • 2015-11-27
        • 2013-04-14
        相关资源
        最近更新 更多