Prevent backslash from being parsed by javascript for a string

Posted by user286269 on Stack Overflow See other posts from Stack Overflow or by user286269
Published on 2010-03-17T04:16:11Z Indexed on 2010/03/17 4:21 UTC
Read the original article Hit count: 341

Filed under:
|
|
|

A Flash AS3 IRC application sends me a string like "f\reak" to my javascript. Irc allows the \ in usernames which poses a problem when its passed to javascript.

"f\reak" become "feak" in javascript making the \r into a carriage return.

Is there a way to read the absolute value of the string instead of parsing a carriage return?

These don't methods didn't work
str.valueOf()
str.toString()
str.charAt(position of the \ ) this just sees the carriage return as well and not a backslash

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about string