开发者

string.replace(/""\n/g,"\"\""+ "\n") will this work?

strin开发者_开发技巧g.replace(/""\n/g,"\"\""+ "\n")

I am trying to parse a string and for using JSON parser. I need to replace the occurrence ""\n (quote, quote, newline) with \\"\\"\n (slash, quote, slash, quote, newline).

I tried to do this by using escape sequence, but am not able to do so.


Try using the single quote (') string form to avoid escaping double-quotes unnecessarily this:

string.replace(/""\n/g, '\\"\\"\n')


Try this regular expression /\"\"[\n|\r]/g

str.replace( /\"\"[\n|\r]/g, '\\"\\"\r' );

It works for me :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜