...And I'm not saying this to dis on the guy... but if he doesn't know how to write a regex to "detect a carriage return", he might not know about the subtleties of the various characters in the big bag known as "return".

"Carriage return" is "\r". It is the control character which actually means to move your cursor (or the carriage on your typewriter/tty) over to the far left margin.

"Line feed Newline" (which might be what you meant but didn't know you meant) is "\n". It is the control character which means to move your cursor (or, etc.) down one line.

To make matters worse, different operating systems have different ideas of what the "Enter" key on your keyboard means and/or what character separates lines in a text file. DOS/Windows, being overly literal, expects both... one to go down a line and one to go back to the left margin "\r\n". Unix, is happy with just the line feed newline (no carriage return) "\n". And MAC, just to be different wants a carriage return (but no line feed newline) "\r". However, just to add to the confusion, different languages/platforms may map all of these combinations to and from a simple "\n" as appropos of the operating system.

Anyway, I just point this out because even though what you asked for was /\r/... it could be that what you need is /\r\n/ or, more likely, /\n/.

Update: as duff points out, I meant to say line feed (referring to the specific control character by name), but said newline instead. Should have man'd ascii quickly before posting so I didn't reverse the terms. My bad.


------------
:Wq
Not an editor command: Wq

In reply to Re: Re: detecting carraige returns by etcshadow
in thread detecting carraige returns by 8BIT

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.