search

Home  >  Q&A  >  body text

javascript - The newline character is not read as \r\n, but directly as \n\n? ?

The data returned in the background is this,

I do not display line breaks on the page, but directly change lines in the html. The point is, I want to use the regular replace:
to find that the newline character is not replaced with /r/n, but \n\n
,

Maybe there is something wrong with my question. In fact, my code is
'a= "Change a new line

Change 2 lines

Hahaha

The above is 3 lines "',
That is, a = 'Change one line nn change 2 lines nnn hahaha nnnn The above is 3 lines',
2 'nn' is a newline character, followed by 1' /n', just change one more line,
I need to use regular expressions to correctly replace these with '
'

Is there any way to solve it? Urgent, urgent, rest,

淡淡烟草味淡淡烟草味2748 days ago752

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-19 10:21:36

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:21:36

    Although you added a description, I still don’t quite understand your problem.

    replace(/[rn]+/, 'n')

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:21:36

    Zero-width assertion:

    reply
    0
  • Cancelreply