JavaScript string with new line - but not using \n

前端 未结 8 2100
故里飘歌
故里飘歌 2020-11-27 05:44

I have a string that has new lines in. I am wanting to convert these to HTML
s, but I\'m having a hard time detecting them.

Imagine a JavaScri

8条回答
  •  天命终不由人
    2020-11-27 06:01

    This is a small adition to @Andrew Dunn's post above

    Combining the 2 is possible to generate readable JS and matching output

     var foo = "Bob\n\
        is\n\
        cool.\n\";
    

提交回复
热议问题