Created
June 16, 2010 10:29
-
-
Save rjp/440443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeRGT(x) { | |
var pos = 0; | |
while (pos < x.length) { | |
var lookin = x.substr(pos); | |
var newpos = lookin.search(/"(.*?)"/); | |
if (newpos == -1) { break; } // run out of things to find | |
var newsearch = lookin.substr(newpos+1); | |
var endpos = newsearch.indexOf('"'); | |
var oldstring = newsearch.substr(0, endpos); | |
var newstring = oldstring.replace(/>/g, '>'); | |
if (newstring != oldstring) { | |
var r = new RegExp('"'+oldstring+'"', 'g'); | |
x = x.replace(r, '"'+newstring+'"'); | |
} | |
pos = pos+newpos+endpos+2+newstring.length-oldstring.length; | |
} | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment