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

How to arrange rows in arbitrary fashion

Expand Messages
  • John Shotsky
    First, let me say thanks to all that have helped in the past.I have really learned a lot from you. Here is the new problem I d like some help on: I would like
    Message 1 of 5 , Jan 25, 2009
    • 0 Attachment
      First, let me say thanks to all that have helped in the past.I have really learned a lot from you.

      Here is the new problem I'd like some help on:
      I would like to arrange rows in an arbitrary fashion within select groups. That is, I don't want to sort them, I want them in the
      order I choose.

      Here is an example:
      [
      Row 1
      Row 2
      Row 3
      Row 4
      Row 5
      Row 6
      ]
      [
      Row 1
      Row 2
      Row 3
      Row 4
      Row 5
      Row 6
      ]
      [
      Row 1
      Row 2
      Row 3
      Row 4
      Row 5
      Row 6
      ]

      I want the clip to put row 5 after row 2 in each group.
      So it would look like this after running the clip:
      [
      Row 1
      Row 2
      Row 5
      Row 3
      Row 4
      Row 6
      ]
      [
      Row 1
      Row 2
      Row 5
      Row 3
      Row 4
      Row 6
      ]
      [
      Row 1
      Row 2
      Row 5
      Row 3
      Row 4
      Row 6
      ]

      I've been playing around with things, but can't seem to select only one group at a time - the find seems too 'greedy'.
      Thanks for any help you can provide.
      John


      [Non-text portions of this message have been removed]
    • Alec Burgess
      This should do what you want I think: ^replace (?s) [ r n(.*? r n)(.*? r n)(.*? r n)(.*? r n)(.*? r n)(.*? r n)] [ r n$1$2$5$3$4$6 r n] rwsai Above is
      Message 2 of 5 , Jan 25, 2009
      • 0 Attachment
        This should do what you want I think:

        ^replace
        "(?s)\[\r\n(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)]" >>
        "[\r\n$1$2$5$3$4$6\r\n]" rwsai

        Above is one long line if it breaks.

        I'm not sure whether you'll want to run it exactly like this every time
        or whether you need wizards or something to control/alter the
        order/number of lines but I think it matches your defined requirements.


        John Shotsky (jshotsky@...) wrote (in part) (on 2009-01-25 at
        13:38):
        > I want the clip to put row 5 after row 2 in each group. So it would
        > look like this after running the clip:
        > [
        > Row 1
        > Row 2
        > Row 5
        > Row 3
        > Row 4
        > Row 6
        > ]
        > [
        > Row 1
        > Row 2
        > Row 5
        > Row 3
        > Row 4
        > Row 6
        > ]
        > [
        > Row 1
        > Row 2
        > Row 5
        > Row 3
        > Row 4
        > Row 6
        > ]
        I've been playing around with things, but can't
        > seem to select only one group at a time - the find seems too 'greedy'.

        --
        Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




        [Non-text portions of this message have been removed]
      • John Shotsky
        Ha ha..I always think I m providing a good example, then someone comes along to show me how my example is not robust enough. So - modifications to the example
        Message 3 of 5 , Jan 25, 2009
        • 0 Attachment
          Ha ha..I always think I'm providing a good example, then someone comes along to show me how my example is not robust enough.

          So - modifications to the example are added below. by the way, there will be text following each row name, but it is sufficient to
          catch by row number, since the rest is just .+\R

          Still want Row 5 to follow row 2 in each case. There are an arbitrary number of rows in each group, but they have identifiable text
          as indicated below, and each group is identifiable because of the delimiters ([ and])

          Here is an improved example:
          [
          Row 1 Text follows all these rows
          Row 2
          Row 3
          Row 75
          Row 76
          Row 4
          Row 5
          Row 6
          ]
          [
          Row 1
          Row 65
          Row 12
          Row 2
          Row 3
          Row 14
          Row 15
          Row 77
          Row 4
          Row 5
          Row 6
          Row 7
          Row 101
          Row 202
          ]
          [
          Row 1
          Row 2
          Row 12
          Row 22
          Row 45
          Row 3
          Row 4
          Row 35
          Row 36
          Row 67
          Row 5
          Row 6
          ]




          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
          Sent: Sunday, January 25, 2009 6:34 PM
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] How to arrange rows in arbitrary fashion

          This should do what you want I think:

          ^replace
          "(?s)\[\r\n(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)]" >>
          "[\r\n$1$2$5$3$4$6\r\n]" rwsai

          Above is one long line if it breaks.

          I'm not sure whether you'll want to run it exactly like this every time
          or whether you need wizards or something to control/alter the
          order/number of lines but I think it matches your defined requirements.

          John Shotsky (jshotsky@... <mailto:jshotsky%40comcast.net> ) wrote (in part) (on 2009-01-25 at
          13:38):
          > I want the clip to put row 5 after row 2 in each group. So it would
          > look like this after running the clip:
          > [
          > Row 1
          > Row 2
          > Row 5
          > Row 3
          > Row 4
          > Row 6
          > ]
          > [
          > Row 1
          > Row 2
          > Row 5
          > Row 3
          > Row 4
          > Row 6
          > ]
          > [
          > Row 1
          > Row 2
          > Row 5
          > Row 3
          > Row 4
          > Row 6
          > ]
          I've been playing around with things, but can't
          > seem to select only one group at a time - the find seems too 'greedy'.

          --
          Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)

          [Non-text portions of this message have been removed]



          [Non-text portions of this message have been removed]
        • Alec Burgess
          Ok ... so you are saying that Row 2 ..... anything .... and Row 5 ..... anything .... are lead-in identifiers which can occur anywhere within a block
          Message 4 of 5 , Jan 25, 2009
          • 0 Attachment
            Ok ... so you are saying that "Row 2 ..... anything ...." and "Row 5
            ..... anything ...." are lead-in identifiers which can occur anywhere
            within a block delimited by "[" and "]"? In following I assume that "Row
            5 ..." always occurs AFTER "Row 2 ..."
            CORRECT? and that "Row 2 ...." is never the very first line after
            opening "[".

            If either of these assumptions is violated they CAN BE accommodated if
            necessary. Post back if unable to figure it out ;-)

            Best approach I think is to divide each block into 4 sections:
            (1) Lines up to and including "Row 2 ... \R " (or actually if MS-DOS
            style linebreaks \r\n).
            (2) Lines after (1) up to but not including "Row 5 ... \R"
            (3) Line beginning with "Row 5 ... " but NOT including its trailing "\R"
            (4) Lines after (3) up to closing "\R]"

            then re-arrange these in the sequence (1) (3) (2) (4) ... note that all
            we are doing (hopefully!!) is moving block (2) down below (3)

            in regex notation - note I used RegexBuddy's free-spacing mode to work
            these out (not yet supported in Notetab alas). This allows free use of
            spaces and linefeeds. Downside is that spaces (eg. in "Row 5") have to
            be represented by X20.

            I used named capturing groups to make it (hopefully) easier to to figure
            out how each component is constructed - This is always a trade off - It
            can be easier to type w/o worrying about the construct for named
            patterns but even a few days later I find regex's I have written and
            debugged can become almost unintelligible:

            #-note the (?=\r\n)'s following the .*?'s say include up to line-feed
            but don't use it up, leave it to be put in the next group. This could
            have been done in other ways but this seemed easiest.

            (?s)
            \[
            (?P<uptoRow2>.*?\r\nRow\x202.*?)(?=\r\n)
            (?P<befRow5>.*?)
            (?P<Row5only>\r\nRow\x205.*?)(?=\r\n)
            (?P<aftRow5>.*?)
            ]

            Replace with: [${uptoRow2}${Row5only}${befRow5}${aftRow5}]

            so:
            ^!replace
            "(?s)\[(?P<uptoRow2>.*?\r\nRow\x202.*?)(?=\r\n)(?P<befRow5>.*?)(?P<Row5only>\r\nRow\x205.*?)(?=\r\n)(?P<aftRow5>.*?)]"
            >> " [${uptoRow2}${Row5only}${befRow5}${aftRow5}]" rwsai

            equivalent not using named capturing groups:
            ^!replace
            "(?s)\[(.*?\r\nRow\x202.*?)(?=\r\n)(.*?)(\r\nRow\x205.*?)(?=\r\n)(.*?)]"
            >> "[$1$3$2$4]" rwsai

            John Shotsky wrote:
            > Ha ha..I always think I'm providing a good example, then someone comes along to show me how my example is not robust enough.
            >
            > So - modifications to the example are added below. by the way, there will be text following each row name, but it is sufficient to
            > catch by row number, since the rest is just .+\R
            >
            > Still want Row 5 to follow row 2 in each case. There are an arbitrary number of rows in each group, but they have identifiable text
            > as indicated below, and each group is identifiable because of the delimiters ([ and])
            >
            > Here is an improved example:
            > [
            > Row 1 Text follows all these rows
            > Row 2
            > Row 3
            > Row 75
            > Row 76
            > Row 4
            > Row 5
            > Row 6
            > ]
            > [
            > Row 1
            > Row 65
            > Row 12
            > Row 2
            > Row 3
            > Row 14
            > Row 15
            > Row 77
            > Row 4
            > Row 5
            > Row 6
            > Row 7
            > Row 101
            > Row 202
            > ]
            > [
            > Row 1
            > Row 2
            > Row 12
            > Row 22
            > Row 45
            > Row 3
            > Row 4
            > Row 35
            > Row 36
            > Row 67
            > Row 5
            > Row 6
            > ]
            >
            >
            >
            >
            > From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
            > Sent: Sunday, January 25, 2009 6:34 PM
            > To: ntb-clips@yahoogroups.com
            > Subject: Re: [Clip] How to arrange rows in arbitrary fashion
            >
            > This should do what you want I think:
            >
            > ^replace
            > "(?s)\[\r\n(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)(.*?\r\n)]" >>
            > "[\r\n$1$2$5$3$4$6\r\n]" rwsai
            >
            > Above is one long line if it breaks.
            >
            > I'm not sure whether you'll want to run it exactly like this every time
            > or whether you need wizards or something to control/alter the
            > order/number of lines but I think it matches your defined requirements.
            >
            > John Shotsky (jshotsky@... <mailto:jshotsky%40comcast.net> ) wrote (in part) (on 2009-01-25 at
            > 13:38):
            >
            >> I want the clip to put row 5 after row 2 in each group. So it would
            >> look like this after running the clip:
            >> [
            >> Row 1
            >> Row 2
            >> Row 5
            >> Row 3
            >> Row 4
            >> Row 6
            >> ]
            >> [
            >> Row 1
            >> Row 2
            >> Row 5
            >> Row 3
            >> Row 4
            >> Row 6
            >> ]
            >> [
            >> Row 1
            >> Row 2
            >> Row 5
            >> Row 3
            >> Row 4
            >> Row 6
            >> ]
            >>
            > I've been playing around with things, but can't
            >
            >> seem to select only one group at a time - the find seems too 'greedy'.
            >>
            >
            >


            [Non-text portions of this message have been removed]
          • Alec Burgess
            Alec Burgess (burnews@aci.on.ca) wrote (in part) (on 2009-01-25 at ... oops .... when copy-dragging to construct the Notetab format regex I removed the
            Message 5 of 5 , Jan 25, 2009
            • 0 Attachment
              Alec Burgess (burnews@...) wrote (in part) (on 2009-01-25 at
              23:44):
              >
              > (?s)
              > \[
              > (?P<uptoRow2>.*?\r\nRow\x202.*?)(?=\r\n) (?P<befRow5>.*?)
              > (?P<Row5only>\r\nRow\x205.*?)(?=\r\n)
              > (?P<aftRow5>.*?)
              > ]

              oops .... when copy-dragging to construct the Notetab format regex I
              removed the line-feed before ?P<befRow5> from the above. It s/b:

              (?s)
              \[
              (?P<uptoRow2>.*?\r\nRow\x202.*?)(?=\r\n)
              (?P<befRow5>.*?)
              (?P<Row5only>\r\nRow\x205.*?)(?=\r\n)
              (?P<aftRow5>.*?)
              ]

              I'm pretty sure (not tested in Notetab - only in RegexBuddy) that the
              ^!replace lines are fine as is.
              > ^!replace
              > "(?s)\[(?P<uptoRow2>.*?\r\nRow\x202.*?)(?=\r\n)(?P<befRow5>.*?)(?P<Row5only>\r\nRow\x205.*?)(?=\r\n)(?P<aftRow5>.*?)]"
              > >> " [${uptoRow2}${Row5only}${befRow5}${aftRow5}]" rwsai
              >
              > equivalent not using named capturing groups:
              > ^!replace
              > "(?s)\[(.*?\r\nRow\x202.*?)(?=\r\n)(.*?)(\r\nRow\x205.*?)(?=\r\n)(.*?)]"
              > >> "[$1$3$2$4]" rwsai


              --
              Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.