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

Re: [Clip] Advanced Search and Replace

Expand Messages
  • "Christian Davén"
    ... Thanks for your help, Jody, but you left one thing out. I want to make the Chapter 1 1§ Text... 2§ Text... look like this: 1/1§ Text... 1/2§ Text...
    Message 1 of 9 , Dec 26, 2000
      -----| Jody wrote: |-----

      > >And so on. What I want is to remove the Chapter nn lines and
      > >combine the chapter and section numbering into one.

      Thanks for your help, Jody, but you left one thing out. I want to make the

      Chapter 1

      1§ Text...
      2§ Text...

      look like this:

      1/1§ Text...
      1/2§ Text...

      (That is, I want to remove the "Chaper nn" lines, BUT, I also want the "nn"
      to appear in front of every line. That's what was bothering me.) Does
      someone know a solution to this?

      Thanks!

      Christian
    • Jody
      Hi Christian, Oops! I thought it looked funny. I can probably find the time to right it, because it looks like fun and I need some of that, but first
      Message 2 of 9 , Dec 26, 2000
        Hi Christian,

        Oops! I thought it looked funny. <g> I can probably find the
        time to right it, because it looks like fun and I need some of
        that, but first tell me if the two spaces in front of the text
        and on the "empty" lines are actually in your text.

        >Thanks for your help, Jody, but you left one thing out. I want to make the
        >
        > Chapter 1
        >
        > 1§ Text...
        > 2§ Text...
        >
        >look like this:
        >
        > 1/1§ Text...
        > 1/2§ Text...
        > (That is, I want to remove the "Chaper nn" lines, BUT, I also
        > want the "nn" to appear in front of every line. That's what was
        > bothering me.) Does someone know a solution to this?

        Happy Clip'n!
        Jody

        http://www.notetab.net

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@...
        mailto:Ntb-Clips-UnSubscribe@...
        http://www.egroups.com/group/ntb-clips
      • "Christian Davén"
        ... Well, to be honest my actual text doesn t look like the examples I gave you. I just wanted to see how you do something like this, and then modify it to fit
        Message 3 of 9 , Dec 27, 2000
          -----| Jody wrote: |-----

          > Oops! I thought it looked funny. <g> I can probably find the
          > time to right it, because it looks like fun and I need some of
          > that, but first tell me if the two spaces in front of the text
          > and on the "empty" lines are actually in your text.

          Well, to be honest my actual text doesn't look like the examples I gave
          you. I just wanted to see how you do something like this, and then modify
          it to fit my needs exactly (I love programming, and wouldn't let you do it
          for me!). But let's pretend the spaces ARE there. ;-)

          Christian
        • Jody
          Hi Christian, ... haha - uh, well, that is why I kept asking because meDon t like it not to work the first time, but since... ... OH, so now it comes out! You
          Message 4 of 9 , Dec 31, 2000
            Hi Christian,

            >> Oops! I thought it looked funny. <g>

            >Well, to be honest my actual text doesn't look like the examples
            >I gave you.

            haha - uh, well, that is why I kept asking because meDon't like
            it not to work the first time, but since...

            >I just wanted to see how you do something like this, and then
            >modify it to fit my needs exactly (I love programming, and
            >wouldn't let you do it for me!). But let's pretend the spaces ARE
            >there. ;-)

            OH, so now it comes out! You are a junkie and want all the fun.
            Yep, I know your type alright! :) Well, I ain't gonna let ya have
            all the fun! I only guarantee the Clip on the following text.

            Chapter 1

            1§ Text... Chapter 1 blah, blah, blah
            2§ Text...
            3§ Text...

            Chapter 2

            1§ Text...
            2§ Text... Chapter 2 blah, blah, blah
            3§ Text...

            Chapter 3

            1§ Text...
            2§ Text...
            3§ Text... Chapter 3 blah, blah, blah

            ;Must extra Chapter line at end of document for search!
            Chapter Chapter 66

            <--- Copy below this line --->
            H=New Chapter Format
            ; Happy New Year and New Millennium Eve
            ; Last Updated 12-31-2000, Sojourner@..., jody
            ^!SetHintInfo Formatting...
            ^!SetScreenUpdate Off
            ^!Jump 1

            :Loop
            ; unselects text from SelectTo line in prep for next chap. block
            ^!Jump Select_End

            ; finds only from BOL, not getting another Chapter on same line
            ^!Find "\n Chapter " SR
            ^!IfError End

            ; jumps to the end of selection and gets character (chap. #)
            ^!Jump Select_End
            ^!Set %Chapter%=^$GetChar$

            ; gets row:col position to select back to
            ^!Set %Start%=^$GetRow$:^$GetCol$

            ; finds next chap. start at BOL and jumps BOL (unselects text)
            ^!Find "\n Chapter " SR
            ^!Jump Select_Start

            ;selects to row:col set above
            ^!SelectTo ^%Start%

            ; replaces all of those funny §'s with a digit in front of it
            ; and spaces when starting at the beginning of line with same
            ; text plus a /, but before it the chapter number. Note: H
            ; option is to change only within selection. Double A option
            ; spells Abraham's wife's name in Bible. ;) (Gen. 17:15)
            ^!Replace "\n {\d§}" >> "\n ^%Chapter%/\1" Sarah
            ; looptie-loop
            ; put the next line in if you want Statusbar hint, but slows down.
            ; I did 5000 sets of the above with it on in about 10 secs in Pro. :)
            ; Must comment out the one at start also.
            ; ^!SetHintInfo Chapter: ^%Chapter%
            ^!Goto Loop

            <--- Copy above this line, right --->
            <--- click over a Library, and --->
            <--- choose "Add from Clipboard" --->

            Happy Clip'n!
            Jody

            http://www.notetab.net

            Subscribe, UnSubscribe, Options
            mailto:Ntb-Clips-Subscribe@...
            mailto:Ntb-Clips-UnSubscribe@...
            http://www.egroups.com/group/ntb-clips
          • Jody
            Hi Christian, ... P.S. I forget if you wanted the Chapter n lines removed or not and scrunched. If so, add a ^!DeleteLine after the 1st Find Chapter and the
            Message 5 of 9 , Dec 31, 2000
              Hi Christian,

              >I just wanted to see how you do something like this, and then
              >modify it to fit my needs exactly (I love programming, and
              >wouldn't let you do it for me!). But let's pretend the spaces ARE
              >there. ;-)

              P.S. I forget if you wanted the Chapter n lines removed or not
              and scrunched. If so, add a ^!DeleteLine after the 1st Find
              Chapter and the IfError and instead of ^!IfError End put
              ^!IfError Scrunch and at the bottom after the ^!Goto Loop add:

              ^!Replace "^p^p" >> "^p" WAS
              ^!IfError Next else Skip_-1
              ^!Jump 1

              That assumes that you do not want any blank lines in the whole
              document. Otherwise, once you find the 1st Chapter line and
              delete it and get the row:col number you will need to DeleteLine
              again, ^!Goto Skip_-1 and DeleteLine once more. At least that is
              the way it works in my head. <g>

              ^!Set %Start%=row:col stuff
              ^!Deleteline
              ^!Deleteline
              ^!Skip_-1
              ^!Deleteline

              or likewise

              ^!Deleteline
              ^!Replace "^p" >> "" SB
              ^!Replace "^p" >> "" S

              Again, I'm shoot'n off the top of my head so you will need to
              play with it till it is right.

              Happy Clip'n!
              Jody

              http://www.notetab.net

              Subscribe, UnSubscribe, Options
              mailto:Ntb-Clips-Subscribe@...
              mailto:Ntb-Clips-UnSubscribe@...
              http://www.egroups.com/group/ntb-clips
            • Jody
              Hi Christian, P.S.S. and goodnite... :) Just to make sure, brace your Find criteria. A RegExpert will need to correct me if I m wrong. This time I think I m
              Message 6 of 9 , Dec 31, 2000
                Hi Christian,

                P.S.S. and goodnite... :)

                Just to make sure, brace your Find criteria. A RegExpert will need
                to correct me if I'm wrong. This time I think I'm right though. <g>

                ^!Find "{\n Chapter }" SR

                And I suppose you need to take the spaces out too, else use could use:

                ^!Find "{\n\s+Chapter }" SR

                for any number of spaces after the new line and before Chapter.

                Happy Clip'n!
                Jody

                http://www.notetab.net

                Subscribe, UnSubscribe, Options
                mailto:Ntb-Clips-Subscribe@...
                mailto:Ntb-Clips-UnSubscribe@...
                http://www.egroups.com/group/ntb-clips
              Your message has been successfully submitted and would be delivered to recipients shortly.