Difference between \r and \n

前端 未结 5 537
粉色の甜心
粉色の甜心 2020-12-02 23:09

What is the difference between \\r and \\n in a regular expression?

Can someone explain it with an example?

5条回答
  •  一整个雨季
    2020-12-02 23:59

    \r and \n are digital representations of the way you would advance to the next line on a typewriter. \r is a carriage return and \n is a newline (also known as a linefeed). On a typewriter, to go to the start of the new line, you would return the carriage to the leftmost position and then feed the paper up a line.

    Unix uses \n to mean new line, Macs prior to OS9 used \r, and Windows uses \r\n.

提交回复
热议问题