Search code examples
javascriptregexurlgoogle-chromesearch-engine

Regexp to translate Google search words with accent marks


I'm using some code to extract from a Google Url the keyword of the search. Thanks to an answer to my previous post ( Extract keyword from Google search in Javascript ) I was able to do this.

But I realized that words using accent marks give me trouble (eg. "chaîne" (French word) is translated "cha%C3%AEne"). Did someone have the same problem and wrote some magical regex ? :-)

Bruno


Solution

  • Just use decodeURI

    decodeURI("cha%C3%AEne");