嘿大家快速的问题,我知道这听起来很奇怪,在JavaScript中做,但我有很好的使用它。我需要能够解析在textarea中传递的字符串,使得转义的十六进制文字“\ x41”或任何不是被处理为四个字符'\''x''4''1',而是作为'A'例如:解析javascript中的十六进制文字
var anA = "\x41";
console.log(anA); //emits "A"
var stringToParse = $(#someTextArea).val(); //using jquery for ease not a req
//lets say that "someTextArea" contains "\x41"
console.log(stringToParse); // equals "\" "x" "4" "1" -- not what i want
console.log(new String(stringToParse)); same as last
console.log(""+stringToParse); still doesnt work
console.log(stringToParse.toString()); failz all over (same result)
我希望能够有stringToParse办法遏制“A”而不是“\ X41” ......正则表达式以外的任何想法?我会带一个正则表达式我想,我只是想办法让JavaScript的做我的竞标:)
我也尝试过valueOf() – Ryan 2012-04-26 02:10:59