how do I replace /n with /r/n?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Livermore

    #1

    how do I replace /n with /r/n?

    I am looking for a way to match the condition where a <line feed>
    character is not preceeded by a <return> character.

    This is what I am using to match when /n isn't preceeded by /r but
    doesn't seem to work...

    (?<!&#xD;)&#xA;

    btw, the usage is within C#. Here is the entire replacement code...

    return System.Text.Reg ularExpressions .Regex.Replace( value,
    "(?<!&#xD;)&#xA ;", "&#xD;&#xA; ");
  • Michael Winter

    #2
    Re: how do I replace /n with /r/n?

    On Wed, 15 Sep 2004 14:43:58 -0500, John Livermore
    <john.livermore @nospm-inginix.com> wrote:

    [snip]
    [color=blue]
    > btw, the usage is within C#.[/color]

    Then may I ask, why aren't you posting in a group related to that language?
    [color=blue]
    > (?<!&#xD;)&#xA;[/color]

    From what I've experienced of Microsoft's regular expression patterns, and
    what you've shown in this post, there are stark differences between them
    and those in Javascript. However, if they are compatible, you'll want

    [^\x0d]\x0a

    What you posted seems to attempt that but as it's not a syntax I
    recognise, I couldn't say if it was correct.

    [snip]

    Good luck,
    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • RobG

      #3
      Re: how do I replace /n with /r/n?

      John Livermore wrote:
      [color=blue]
      > I am looking for a way to match the condition where a <line feed>
      > character is not preceeded by a <return> character.
      >
      > This is what I am using to match when /n isn't preceeded by /r but
      > doesn't seem to work...[/color]

      <--snip-->

      In JavaScript, newline (linefeed) is "\n", not "/n" and a carriage return is "\r" not "/r".

      Comment

      Working...