javascript - Curly Brackets Converted to Hexidecimal when using URL.Document or window.location.href -


would take document.url, find string curly brackets, remove curly brackets, , show string inside curly brackets. however, seems document.url or window.location.href convert curly brackets hexidecimal values (%7b & %7d) , can't match against actual {string}. appreciated.

  var txt = document.url; // url http://site.com/somepage&value0={string}   var re1='.*?';    // non-greedy match on filler   var re2='(\\{.*?\\})';    // curly braces 1    var p = new regexp(re1+re2,["i"]);   var m = p.exec(txt);    if (m != null)   {       var cbraces1=m[1];       document.write(cbraces1.replace("{","").replace("}",""));   } 

use decodeuri(document.url) first.

var txt = decodeuri(document.url); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -