Loading ...
Sorry, an error occurred while loading the content.

18476Re: [Clip] Insert blank line between every line of text

Expand Messages
  • Flo
    Oct 5, 2008
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...>
      wrote:
      >
      > Okay, I give?
      > .\K is what? anything but a line end?
      > (?!\r\n|\Z)
      > is not followed by another return or by file end? Is \Z a file end.
      > | means or, correct?...

      Don,

      Regarding \K: "Do\Kn", for example, matches "Don" but returns the "n"
      only. We could also use a Positive Lookbehind Assertion "(?<=Do)n"
      ("Do" preceding "n") but I like \K because it's shorter and, in
      different cases, it doesn't a demand a fixed length of the pattern.
      It just "dismisses" anything that precedes \K.

      ".\K\r\n(?!\r\n|\Z)" matches any single character "." followed by a
      CR/NL without selecting (and replacing) this character. The CR/NL
      must not be followed by another CR/NL (Negative Lookahead Assertion).
      So the replacing doubles any CR/NL but skips over CR/NL in empty
      lines.

      If we've got an empty line following the last CR/NL, also this CR/NL
      would be doubled because we've got a single character, a CR/NL and no
      following CR/NL. To prevent this, an alternative \Z (matches at end
      of string) is used as part of the Assertion (no CR/NL at end of
      string).

      Flo
       
    • Show all 11 messages in this topic