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

19076[Clip] Re: Handling periods at ends of lines

Expand Messages
  • Flo
    Apr 7, 2009
      --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > Thank you again, I was still missing how the dot was working when
      > looking at the clip and looking at my sample....

      John,

      Let me first try again to clear the job you want to do.

      My test lines are...

      This is an example line without a period
      Another line with a period.
      This is an example line with a period.
      Another line without a period
      This is an example line without a period

      I understand that you want to add a period to line #1 and #5 only. That is, to lines which (a) contain the sample string "This is an example line", and which (b) don't end with a period.

      So here's another proposal which combines Sheri's approach with the sample string...

      ^!Replace "^(This is an example line.*)[^\r\n.]\K$" >> "." AWRS

      It adds a period to line #1 and #5 only. The rest is ignored. Is this the job you want to do?

      Maybe I misunderstood the whole issue and you want to add a period to ANY line that doesn't end with a period. In this case, Sheri's proposal...

      ^!Replace "[^\r\n.]\K$" >> "." AWRS

      would the job, of course.

      Flo


      P.S. to Alec:

      Your first solution (without ?m)...

      ^!replace "(?<!\.)$" >> "." rwsai

      works fine for me too. Since it adds a period to ANY line that doesn't end with a period it possibly doesn't meet the job (matching that sample string) (??)

      > Another way is:
      > ^!replace "(?m)([^\.])$" >> "$1." rwsai

      This doesn't work for me. It "splits" the CRNL at the end of each line because, with [^\.], also the CR is matched. So, at the end of line #1 to #4, we get ".CR.CRNL".

      By the way: We don't have to escape the dot here -- inside a character class, it's always regarded as a literal dot.
       
    • Show all 23 messages in this topic