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

Re: RE: [Clip] Fwd: appending lines...

Expand Messages
  • Alec Burgess
    ... (1) My recollection of Rowan s original problem statement was that it eliminated the blank line between the groups of three - yours doesn t. (2) Error
    Message 1 of 16 , Apr 14, 2004
    • 0 Attachment
      Hugo:

      > ^!Replace {.+}\n{.+}\n{.+} >> \1\t\2\t\3 RAWS

      (1) My recollection of Rowan's original problem statement was that it
      eliminated the blank line between the groups of three - yours doesn't.

      (2) Error conditions - yours doesn't insist on a blank line after exactly
      three non blank lines - probably not a problem if the source was generated
      by another program.

      (3) I was surprised that yours worked at all since "find clause" and
      "replace clause" weren't enclosed in quotes. I'd always thought the format
      was either use quotes and >> or no-quotes and tab-separator. I haven't
      checked but maybe its like folder-file paths: quotes required if clause
      contains literal blanks?

      (4) I'd used:
      ^!replace "^{[^\s].*}\n{[^\s].*}\n{[^\s].*}\n\n" >> "\1\t\2\t\3\n" rwsa
      because I wasn't sure if the intervening empty lines might have actually had
      one or (or more) spaces instead of being truly empty. As well, if the
      intervening blank line is desired
      \1\t\2\t\3\n could be changed to \1\t\2\t\3\n\n
      I also haven't tested to see if that accidentally solves the boundary
      conditions Alan and hrs had noted. - Yours is definitely more elegant if the
      source document is formatted so that it works :-)

      > BTW Alec, the link you sent is dead...
      RegexDesigner
      http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01e0dfb7-0182-45cd-94f7-2ed2df2504a9
      Its a godotnet link so maybe its temporary - I got it Mar-24-2004 so it may
      be only temporarily dead.

      >I have installed another regex
      > program that I never use (like so many of those uilities),

      If I ever try to use more complicated regexp's I expect I'll make more use
      of it (say when Notetab 5.0 is available next week <GRIN>)

      > but I think you
      > may want to play with it for a while...
      > RegEx coach: http://weitz.de/regex-coach/

      I'm glad you mentioned this - its the one I had meant, and is *much better*
      than RegexDesigner (unless perhaps you are a programmer) - I didn't check
      carefully enough when I pulled the link from my records :-(


      Regards ... Alec
      --
      ----- Original Message -----
      From: "Hugo Paulissen" <hugopaulissen@...>
      To: <ntb-clips@yahoogroups.com>
      Sent: Wednesday, April 14, 2004 16:20
      Subject: [gla: RE: [Clip] Fwd: appending lines...
    • Alan C.
      ... [ . . ] ... [ . . ] ... I knew about the last group but distracted/overlooked/forgot to implement a fix for it until you brought it to my attention. ^!Jump
      Message 2 of 16 , Apr 15, 2004
      • 0 Attachment
        On Wed, 14 Apr 2004 08:09:59 -0500, hsavage wrote:
        >�Alec Burgess wrote:
        [ . . ]
        >�Alec, Alan,
        >
        >�Neither regexp line works correctly for me, you are getting closer!
        [ . . ]
        >�-- Alan's line and trouble encountered;
        >
        >�h=test4
        >� leaves no blank line between revised groups - misses last 3 line group
        >�^!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
        ; ---<end. fixes for missed last group

        As to leaves no blank line between revised groups: The O.P. expressed it like that, minus any blank line, as per next snippet from former post at least in the post that I got.

        >>>�I've got a text document with the ff:
        >>>
        >>>�line1
        >>>�line2
        >>>�line3
        >>>
        >>>�line1
        >>>�line2
        >>>�line3
        >>>
        >>>�etc...
        >>>
        >>>�Is there a way I could append the lines together separated by a TAB
        >>>�character i.e.
        >>>
        >>>�line1^Tline2^Tline3^P
        >>>�line1^Tline2^Tline3^P

        --
        Alan.
        (joke): I think I'll adopt a change in strategy. Instead of trying to go too fast much of the time, I think I'll now try to go too slow. This will be a test. And, perhaps I'll get more done.
      • Hugo Paulissen
        Okay, I ve now read the original question in Alans post. It is easy to do without regular expressions... and you can do it in a two-step search and replace as
        Message 3 of 16 , Apr 15, 2004
        • 0 Attachment
          Okay,

          I've now read the original question in Alans post. It is easy to do without
          regular expressions... and you can do it in a two-step search and replace as
          well...

          ^!Replace ^P >> ^T AW
          ^!Replace ^T^T >> ^P AW

          In general I hesitate to advise too complex regular expressions since it
          seems to end in discussions about the original file format - at least if we
          don't get a snippet from the actual file that needs to be processed.

          ("Well, actually, there is a whitespace after that line, and yes, there are
          more than five digits at the beginning of each line, but sometimes they are
          preceded with... so why doesn't it work???")

          Regards,

          Hugo

          > -----Oorspronkelijk bericht-----
          > Van: Alan C. [mailto:acumming@...]
          > Verzonden: donderdag 15 april 2004 11:17
          > Aan: ntb-clips@yahoogroups.com
          > Onderwerp: Re: [Clip] Fwd: appending lines...
          >
          >
          > On Wed, 14 Apr 2004 08:09:59 -0500, hsavage wrote:
          > > Alec Burgess wrote:
          > [ . . ]
          > > Alec, Alan,
          > >
          > > Neither regexp line works correctly for me, you are getting closer!
          > [ . . ]
          > > -- Alan's line and trouble encountered;
          > >
          > > h=test4
          > > leaves no blank line between revised groups - misses last 3 line group
          > > ^!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
          > ; ---<end. fixes for missed last group
          >
          > As to leaves no blank line between revised groups: The O.P.
          > expressed it like that, minus any blank line, as per next snippet
          > from former post at least in the post that I got.
          >
          > >>> I've got a text document with the ff:
          > >>>
          > >>> line1
          > >>> line2
          > >>> line3
          > >>>
          > >>> line1
          > >>> line2
          > >>> line3
          > >>>
          > >>> etc...
          > >>>
          > >>> Is there a way I could append the lines together separated by a TAB
          > >>> character i.e.
          > >>>
          > >>> line1^Tline2^Tline3^P
          > >>> line1^Tline2^Tline3^P
          >
          > --
          > Alan.
          > (joke): I think I'll adopt a change in strategy. Instead of
          > trying to go too fast much of the time, I think I'll now try to
          > go too slow. This will be a test. And, perhaps I'll get more done.
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
        • 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 4 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 5 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 6 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 7 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.