string.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.
尝试使用单引号( '
)字符串形式,以避免不必要地转义双引号:
string.replace(/""\n/g, '\\"\\"\n')
Try this regular expression /\\"\\"[\\n|\\r]/g
str.replace( /\\"\\"[\\n|\\r]/g, '\\\\"\\\\"\\r' );
It works for me :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.