A better JavaScript version of addslashes and stripslashes?

Posted by karlthorwald on Stack Overflow See other posts from Stack Overflow or by karlthorwald
Published on 2010-04-08T13:11:37Z Indexed on 2010/04/08 13:23 UTC
Read the original article Hit count: 469

Filed under:
|

I am using these 2 functions:

http://javascript.about.com/library/bladdslash.htm

But JSLint complains 'Bad Escapement' on this line:

str=str.replace(/\\0/g,'\0');

[Edit]

I converted to 2 lines, and now the first line is the one that fails JLint:

var rep = '\0';
str=str.replace(/\\0/g,rep);

So it is the

'\0'

can you help? I could try something but I want to understand what is going on.

[/Edit]

Can you make a better version and explain?

I would like a version that passes JSLint and still works.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jslint