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

Re: appending lines...

Expand Messages
  • Rowel I. Lirag
    Hi everyone, Thanks for all the help I got appending lines together. Really made my day and certainly convinced several friends about the worthiness of
    Message 1 of 16 , Apr 15, 2004
    • 0 Attachment
      Hi everyone,

      Thanks for all the help I got appending lines together.
      Really made my day and certainly convinced several friends
      about the worthiness of NoteTab.


      ROWEL

      ---
      Alan wrote:
      ^!Replace "{\B.+}\n{\B.+}\n{\B.+}\n\n" >"\1\t\2\t\3\n" WRSA

      I knew about the last group but distracted/overlooked/forgot to
      implement a fix for it until you brought it to my attention.

      ^!Jump DOC_END
      ^!InsertText ^p^p
      ^!Replace "{\B.+}\n{\B.+}\n{\B.+}\n\n" >"\1\t\2\t\3\n" RWSA
    • Rowel I. Lirag
      Ok, I ve got another problem and I know you guys can help me. Sometimes, the blocks of Lines 1 to 3 are nicely separated w/ a single newline. There are times,
      Message 2 of 16 , Apr 15, 2004
      • 0 Attachment
        Ok, I've got another problem and I know you guys can help me.
        Sometimes, the blocks of Lines 1 to 3 are nicely separated
        w/ a single newline. There are times, though, that the newline
        is missing b/w the blocks or there are more than one newline
        separating the blocks as show below.

        How can I append the block of lines (1 to 3) together so that it will
        also will handle the exceptions mentioned above?


        Line1
        Line2
        Line3

        Line1
        Line2
        Line3



        Line1
        Line2
        Line3

        Line1
        Line2
        Line3
        Line1
        Line2
        Line3
      • hsavage
        ... Rowel, Here are 2 slightly altered regexp ^!Replace lines from Alan and Hugo. Both will give you the single spaced lines despite the lack of line space or
        Message 3 of 16 , Apr 15, 2004
        • 0 Attachment
          Rowel I. Lirag wrote:

          > How can I append the block of lines (1 to 3) together so that it will
          > also will handle the exceptions mentioned above?
          >
          > Line1
          > Line2
          > Line3
          >
          >
          >
          > Line1
          > Line2
          > Line3
          >
          > Line1
          > Line2
          > Line3
          > Line1
          > Line2
          > Line3

          Rowel,

          Here are 2 slightly altered regexp ^!Replace lines from Alan and Hugo.
          Both will give you the single spaced lines despite the lack of line
          space or additional line space.

          ; line from Alan, slightly altered
          ^!Replace "{\B.+}\n{\B.+}\n{\B.+}\n+" >> "\1\t\2\t\3\n\n" TIWRSA


          ; line from Hugo, slightly altered
          ^!Replace {.+}\n{.+}\n{.+}\n+ >> \1\t\2\t\3\n\n TIWRSA


          You will have a double linespace at the end but you can patch from the
          clips you've already received to eliminate that if you want.

          hrs
        • Alan C.
          ... I got to tinkering with it a bit more. In your enclosed data sample further below I added a tab on one blank line and two spaces on another succeeding
          Message 4 of 16 , Apr 16, 2004
          • 0 Attachment
            On Thu, 15 Apr 2004 14:50:21 -0000, Rowel I. Lirag wrote:
            >
            > Ok, I've got another problem and I know you guys can help me.
            > Sometimes, the blocks of Lines 1 to 3 are nicely separated
            > w/ a single newline. There are times, though, that the newline
            > is missing b/w the blocks or there are more than one newline
            > separating the blocks as show below.
            >
            > How can I append the block of lines (1 to 3) together so that it will
            > also will handle the exceptions mentioned above?

            I got to tinkering with it a bit more.

            In your enclosed data sample further below I added a tab on one blank line and two spaces on another succeeding blank line.

            The next will cover for what you seek above it will also cover for the tab and spaces that I added onto your sample (cleans em up as last step of clip's run).

            ^!Jump DOC_END
            ^!InsertText ^p^p
            ^!Replace "{\B.+}\n{\B.+}\n{\B.+}\n+" >> "\1\t\2\t\3\n" RWSA
            ^!Replace "^\b\b*" >> "" RWSA

            The above processes each three line sequence whereby text *must at least begin each of the three lines.

            The next clip also do what you seek above (and it cleans up tab and space at end too). Differently, the next finds *one line which must begin with text -- then it selects that line as well as the next two lines for a total of three lines to process at a time.

            ^!Jump DOC_START
            :repeat
            ^!Find "^\B.+" RS
            ^!IfError last
            ^!Select 3
            ^!Replace "\n" >> "\t" RHSA
            ^!Replace "\t$" >> "" RHS
            ^!Goto repeat
            :last
            ^!Replace "^\b\b*" >> "" RWSA
            ; ----<end

            When I tried Hugo's clip on next sample, the lines with tab(s) and space(s) on them got processed just as if they were lines containing your text records. That is what the \B and the \b are for they either prerequisite only_text or prerequisite only_*not_text. Text is text, alpha, numeric, comma, etc. And, well, not_text can be: newline, tab, space, form feed, etc.

            Now then, not that any of these clips are any better than any of the other clips. Knowing your data is important and target the script/clip design accordingly. If you know that there will never be any tab(s) or space(s) on any of your blank lines then Hugo's clip hits the target right on. And it may possibly also even do the job faster than the code I've shared here.

            Just come to mind that on *very large files, regex on Notetab can sometimes be perhaps too slow. In such case a repetitive loop instead of regex can be the ticket to greater efficiency.

            I sometimes get fascinated by regex and like to dabble and explore in it. If I don't then it gets forgotten. Thanks everyone.
            >
            >
            > Line1
            > Line2
            > Line3
            >
            > Line1
            > Line2
            > Line3
            >TAB
            >SPACESPACE
            > Line1
            > Line2
            > Line3
            >
            > Line1
            > Line2
            > Line3
            > Line1
            > Line2
            > Line3

            --
            Alan.
          Your message has been successfully submitted and would be delivered to recipients shortly.