Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
158
rated 0 times [  163] [ 5]  / answers: 1 / hits: 42344  / 14 Years ago, wed, november 17, 2010, 12:00:00

I have a string in JS in this format:



httpx3ax2fx2fwww.url.com



How can I get the decoded string out of this? I tried unescape(), string.decode but it doesn't decode this. If I display that encoded string in the browser it looks fine (http://www.url.com), but I want to manipulate this string before displaying it.



Thanks.


More From » javascript

 Answers
14

You could write your own replacement method:



String.prototype.decodeEscapeSequence = function() {
return this.replace(/\x([0-9A-Fa-f]{2})/g, function() {
return String.fromCharCode(parseInt(arguments[1], 16));
});
};
http\x3a\x2f\x2fwww.example.com.decodeEscapeSequence()

[#94930] Monday, November 15, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shaina

Total Points: 161
Total Questions: 99
Total Answers: 108

Location: American Samoa
Member since Fri, Sep 24, 2021
3 Years ago
;