What is the difference between \\r
and \\n
in a regular expression?
Can someone explain it with an example?
\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
.