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

Re: [NTS] Changing CR & LF

Expand Messages
  • buralex@gmail.com
    Art Kocsis said on Jun 03, 2008 23:16 -0400 (in ... Use it enough and you ll start trying to enter Regex in the Google toolbar. it
    Message 1 of 16 , Jun 4, 2008
    • 0 Attachment
      Art Kocsis <artkns@...> said on Jun 03, 2008 23:16 -0400 (in
      part):
      > RegEx rocks!!! [But I do wish it had easier syntax.]
      Use it enough and you'll start trying to enter Regex in the Google toolbar.
      <tip> it doesn't work :-) </tip>

      More seriously - if you want to get a better handle on Regex syntax
      RegexBuddy is the way to go. And it has a forum as helpful as the
      Notetab group of mail lists. (Fortunately not as active)

      I use RegexBuddy for almost every non-trivial regex I attempt in Notetab
      then just paste the "correct" expression back into a ^!Find or ^!Replace
      statement.

      Regards ... Alec -- buralex-gmail
      --



      [Non-text portions of this message have been removed]
    • Art Kocsis
      Even though it s kind of embarrassing to display a kludgy clip, I thought I would share this in the hopes that it would inspire other RegEx beginners to learn
      Message 2 of 16 , Jun 12, 2008
      • 0 Attachment
        Even though it's kind of embarrassing to display a kludgy clip, I thought I
        would share this in the hopes that it would inspire other RegEx beginners
        to learn and use RegEx.

        Years ago I got tired of all the empty lines in HTML pages that I was editing
        (largely due to WYSIWYG editors such as FrontPage), I decided to write a
        clip to get rid of them. I don't know if this was my first clip or not but
        it was
        early. One of my big problems was handling the various line terminators -
        CR, LF, CRLF - that appeared in the code. I did not learn until last month
        that they were all converted to CRLF in the working image. Even so, the ^P
        token did not work consistently so I came up with this scheme. It worked
        but was quite slow. Finally losing patience with its slowness, I decided to
        redo the clip using RegEx. As you know, with your help, I was successful.
        Below, for your amusement/education/motivation are the before & after clips.

        Three lessons can be learned:

        1) Even kludges can be made to work and are useful. Keep trying.
        2) RegEx is quite esoteric yet is conquerable and is extremely efficient.
        3) We need better documentation, especially a User Guide.

        Enjoy, Art

        Note: NoteTab has EXTREMELY picky syntax. When it says "space delimited"
        that means a SINGLE space - two or more spaces => "syntax error"!

        ;^!Replace "SearchText" >> "ReplaceText" [Options TCIBGWHRSA]
        ; W: Whole. Search entire document (not just from the cursor position).
        ; S: Silent. NoteTab will not display any message box.
        ; A: All. Replace matched occurrences, not just first one.
        ;
        ; "ALT+M" invokes the Modify menu
        ; "L" invokes the Lines submenu
        ; "T" trims the selected text


        ;######### Old, Non-RegEx Clip. Could take 30 sec or more on a 40K file
        ^!StatusShow Running Single Space
        ^!Toolbar Select All
        ^!Keyboard ALT+M L T
        ^!Replace "^L" >> "^C" WSA
        ^!Replace "^C^C^C^C^C^C" >> "^C" WSA
        ^!Replace "^C^C^C^C^C" >> "^C" WSA
        ^!Replace "^C^C^C^C" >> "^C" WSA
        ^!Replace "^C^C^C" >> "^C" WSA
        ^!Replace "^C^C" >> "^C" WSA
        ^!Replace "^C" >> "^P" WSA
        ^!Jump Doc_Start


        ;######### New, RegEx Clip. Takes a fraction of a second on even very large
        files
        ^!StatusShow Running Single Space
        ^!Toolbar Select All
        ^!Keyboard ALT+M L T
        ^!Replace "\R+" >> "^%NL%" ARSTW
        ^!Jump Doc_Start
      • John Shotsky
        Art, ^!Replace R+ ^%NL% ARSTW Will change your paragraph spacing, because any paragraph separation lines will disappear. If you want to retain a blank
        Message 3 of 16 , Jun 12, 2008
        • 0 Attachment
          Art,

          ^!Replace "\R+" >> "^%NL%" ARSTW


          Will change your paragraph spacing, because any paragraph separation lines will disappear.
          If you want to retain a blank line between paragraphs, it should be:

          ^!Replace "\R" >> "^%NL%" ARSTW

          John

          From: ntb-scripts@yahoogroups.com [mailto:ntb-scripts@yahoogroups.com] On Behalf Of Art Kocsis
          Sent: Thursday, June 12, 2008 3:55 PM
          To: NoteTab-Scripts
          Subject: Re: [NTS] Changing CR & LF

          Even though it's kind of embarrassing to display a kludgy clip, I thought I
          would share this in the hopes that it would inspire other RegEx beginners
          to learn and use RegEx.

          Years ago I got tired of all the empty lines in HTML pages that I was editing
          (largely due to WYSIWYG editors such as FrontPage), I decided to write a
          clip to get rid of them. I don't know if this was my first clip or not but
          it was
          early. One of my big problems was handling the various line terminators -
          CR, LF, CRLF - that appeared in the code. I did not learn until last month
          that they were all converted to CRLF in the working image. Even so, the ^P
          token did not work consistently so I came up with this scheme. It worked
          but was quite slow. Finally losing patience with its slowness, I decided to
          redo the clip using RegEx. As you know, with your help, I was successful.
          Below, for your amusement/education/motivation are the before & after clips.

          Three lessons can be learned:

          1) Even kludges can be made to work and are useful. Keep trying.
          2) RegEx is quite esoteric yet is conquerable and is extremely efficient.
          3) We need better documentation, especially a User Guide.

          Enjoy, Art

          Note: NoteTab has EXTREMELY picky syntax. When it says "space delimited"
          that means a SINGLE space - two or more spaces => "syntax error"!

          ;^!Replace "SearchText" >> "ReplaceText" [Options TCIBGWHRSA]
          ; W: Whole. Search entire document (not just from the cursor position).
          ; S: Silent. NoteTab will not display any message box.
          ; A: All. Replace matched occurrences, not just first one.
          ;
          ; "ALT+M" invokes the Modify menu
          ; "L" invokes the Lines submenu
          ; "T" trims the selected text

          ;######### Old, Non-RegEx Clip. Could take 30 sec or more on a 40K file
          ^!StatusShow Running Single Space
          ^!Toolbar Select All
          ^!Keyboard ALT+M L T
          ^!Replace "^L" >> "^C" WSA
          ^!Replace "^C^C^C^C^C^C" >> "^C" WSA
          ^!Replace "^C^C^C^C^C" >> "^C" WSA
          ^!Replace "^C^C^C^C" >> "^C" WSA
          ^!Replace "^C^C^C" >> "^C" WSA
          ^!Replace "^C^C" >> "^C" WSA
          ^!Replace "^C" >> "^P" WSA
          ^!Jump Doc_Start

          ;######### New, RegEx Clip. Takes a fraction of a second on even very large
          files
          ^!StatusShow Running Single Space
          ^!Toolbar Select All
          ^!Keyboard ALT+M L T
          ^!Replace "\R+" >> "^%NL%" ARSTW
          ^!Jump Doc_Start



          [Non-text portions of this message have been removed]
        • Alec Burgess
          ... Just a couple of comments Art: As always there are many ways to skin the cat, in Notetab clips. I usually use them is this order: - Native command (looking
          Message 4 of 16 , Jun 12, 2008
          • 0 Attachment
            On Thu, Jun 12, 2008 at 6:54 PM, Art Kocsis <artkns@...> wrote:

            > ;######### New, RegEx Clip. Takes a fraction of a second on even very large
            >
            > files
            > ^!StatusShow Running Single Space
            > ^!Toolbar Select All
            > ^!Keyboard ALT+M L T
            > ^!Replace "\R+" >> "^%NL%" ARSTW
            > ^!Jump Doc_Start
            >

            Just a couple of comments Art:
            As always there are many ways to skin the cat, in Notetab clips. I usually
            use them is this order:

            - Native command (looking for a native command in Clip Help assists in
            learning others I may not have even realized exist)
            - Menu Command
            - Toolbar Command (actually I never use these - I think ALL Toolbar
            commands are available from menu.)
            - Keyboard Command - avoid like the plague - hard to figure out what they
            do, may require Waits to work correctly, (however they ARE necessary when
            trying to drive an external window from within Notetab)

            so:

            > ^!Toolbar Select All
            > ^!Keyboard ALT+M L T
            >
            would be:

            > ^!select ALL
            > ; or optionally ^!Menu Edit/"Select All";
            > ^!Menu Modify/Lines/Trim Blanks"


            what say the rest of the regular contributors?
            --
            Regards ... Alec
            --


            [Non-text portions of this message have been removed]
          • Art Kocsis
            Thank you for your interest John, but my clip does exactly what I want to do: change an entire document to single spacing, i.e,, change every instance of one
            Message 5 of 16 , Jun 12, 2008
            • 0 Attachment
              Thank you for your interest John, but my clip does exactly what I want
              to do: change an entire document to single spacing, i.e,, change every
              instance of one or more consecutive newlines to a single newline. Your
              clip is, in essence, a null clip as it just replaces each instance of a
              newline with a newline. Compare the two expressions operating on a
              multiply spaced document.

              Namaste', Art


              At 6/12/2008 04:02 PM, you wrote:
              >Art,
              >
              >^!Replace "\R+" >> "^%NL%" ARSTW
              >
              >Will change your paragraph spacing, because any paragraph separation lines
              >will disappear.
              >If you want to retain a blank line between paragraphs, it should be:
              >
              >^!Replace "\R" >> "^%NL%" ARSTW
              >
              >John
              >
              >From: <mailto:ntb-scripts%40yahoogroups.com>ntb-scripts@yahoogroups.com On
              >Behalf Of Art Kocsis
              >Sent: Thursday, June 12, 2008 3:55 PM
              >To: NoteTab-Scripts
              >Subject: Re: [NTS] Changing CR & LF
              >
              >Even though it's kind of embarrassing to display a kludgy clip, I thought I
              >would share this in the hopes that it would inspire other RegEx beginners
              >to learn and use RegEx.
              >
              >Years ago I got tired of all the empty lines in HTML pages that I was editing
              >(largely due to WYSIWYG editors such as FrontPage), I decided to write a
              >clip to get rid of them. I don't know if this was my first clip or not but
              >it was
              >early. One of my big problems was handling the various line terminators -
              >CR, LF, CRLF - that appeared in the code. I did not learn until last month
              >that they were all converted to CRLF in the working image. Even so, the ^P
              >token did not work consistently so I came up with this scheme. It worked
              >but was quite slow. Finally losing patience with its slowness, I decided to
              >redo the clip using RegEx. As you know, with your help, I was successful.
              >Below, for your amusement/education/motivation are the before & after clips.
              >
              >Three lessons can be learned:
              >
              >1) Even kludges can be made to work and are useful. Keep trying.
              >2) RegEx is quite esoteric yet is conquerable and is extremely efficient.
              >3) We need better documentation, especially a User Guide.
              >
              >Enjoy, Art
              >
              >Note: NoteTab has EXTREMELY picky syntax. When it says "space delimited"
              >that means a SINGLE space - two or more spaces => "syntax error"!
              <snip>
              >;######### New, RegEx Clip. Takes a fraction of a second on even very large
              >files
              >^!StatusShow Running Single Space
              >^!Toolbar Select All
              >^!Keyboard ALT+M L T
              >^!Replace "\R+" >> "^%NL%" ARSTW
              >^!Jump Doc_Start
            • Art Kocsis
              HI Alec, This says it all: learning others I may not have even realized exist I had originally coded the Trim as: ^!Keyboard ALT+M O &100 L O &100 T But it
              Message 6 of 16 , Jun 12, 2008
              • 0 Attachment
                HI Alec,

                This says it all: "learning others I may not have even realized exist"

                I had originally coded the Trim as:

                ^!Keyboard ALT+M O &100 L O &100 T

                But it didn't work so I did the

                ^!Keyboard ALT+M L T

                which did work, but is esoteric.

                After learning about ^!Toolbar, I tried as it would be self-documenting:

                ^!Toolbar Trim Blanks

                but that didn't work because, as you know, it's not on a toolbar! So
                I gave up and went back to what worked.

                So thanks for the tip. I didn't know about the ^!Select ALL or ^!Menu
                until now. It is much better and is what I had wanted to do all along.

                Getting back to the Clip Help file it is huge and I find I spend a huge
                amount of time searching it, even for stuff I have seen before let alone
                commands or techniques of which I am not aware. There are not
                enough internal links and the organization is frequently not the way
                that I think. To find all these tidbits I would need to read the file end
                to end a few times which would take forever. In the meantime, I am
                collecting the various command names that I use or that look promising
                into a single sorted file. Maybe that will help. Thankfully there is this list
                that reap the benefit of other eyes reading the help file, like

                "trying to drive an external window from within Notetab" ?? Was ist??

                Thanks again, Art


                At 6/12/2008 08:39 PM, you wrote:
                >On Thu, Jun 12, 2008 at 6:54 PM, Art Kocsis
                ><<mailto:artkns%40sbcglobal.net>artkns@...> wrote:
                >
                > > ;##### New, RegEx Clip. Takes a fraction of a second on even very large
                > files
                > >
                > > ^!StatusShow Running Single Space
                > > ^!Toolbar Select All
                > > ^!Keyboard ALT+M L T
                > > ^!Replace "\R+" >> "^%NL%" ARSTW
                > > ^!Jump Doc_Start
                > >
                >Just a couple of comments Art:
                >As always there are many ways to skin the cat, in Notetab clips. I usually
                >use them is this order:
                >
                >- Native command (looking for a native command in Clip Help assists in
                >learning others I may not have even realized exist)
                >- Menu Command
                >- Toolbar Command (actually I never use these - I think ALL Toolbar
                >commands are available from menu.)
                >- Keyboard Command - avoid like the plague - hard to figure out what they
                >do, may require Waits to work correctly, (however they ARE necessary when
                >trying to drive an external window from within Notetab)
                >
                >so:
                >
                > > ^!Toolbar Select All
                > > ^!Keyboard ALT+M L T
                > >
                >would be:
                >
                > > ^!select ALL
                > > ; or optionally ^!Menu Edit/"Select All";
                > > ^!Menu Modify/Lines/Trim Blanks"
                >
                >what say the rest of the regular contributors?
                >--
                >Regards ... Alec
              Your message has been successfully submitted and would be delivered to recipients shortly.