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 :)
精彩评论