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

Re: [Clip] Collecting a list from a document

Expand Messages
  • joy8388608
    ... If you replace the third line with the following ^!SetClipboard ^$GetDocMatchAll( (?s)(^Title::)([^ r n]+) ;2)$ your results will leave out the Title::
    Message 1 of 13 , Dec 27, 2011
      --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > Thanks. I got it working with the following:
      >
      > ^!Jump 1
      > ^!SetListDelimiter ^p
      > ^!SetClipboard ^$GetDocMatchAll("(?s)^Title::[^\r\n]+")$
      > ^!TOOLBAR New Document
      > ^!TOOLBAR Paste
      > ^!Save As titles.txt
      >
      > Regards,
      > John


      If you replace the third line with the following
      ^!SetClipboard ^$GetDocMatchAll("(?s)(^Title::)([^\r\n]+)";2)$
      your results will leave out the Title:: that precedes each line.

      While we're at it, can someone explain the difference between \R vrs \r\n? I know enough to try both when having trouble but am not clear on the difference.

      Joy
    • Don
      ... Newline sequences Outside a character class, by default, the escape sequence R matches any Unicode newline sequence. This is a Perl 5.10 feature. In
      Message 2 of 13 , Dec 27, 2011
        On 12/27/2011 10:29 AM, joy8388608 wrote:
        > While we're at it, can someone explain the difference between \R vrs \r\n? I know enough to try both when having trouble but am not clear on the difference.

        Newline sequences

        Outside a character class, by default, the escape sequence \R matches
        any Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8
        mode \R is equivalent to the following:

        (?>\r\n|\n|\x0b|\f|\r|\x85)

        See help > help on regular expressions > Contents (tab) > New Line
        Conventions

        \R is essentially "greater" than \r or \n (most often used in sequence,
        one is the return and the other is the new line. I think that the way
        it is used in this clip, not \r and not \n is using them in the
        alternative. [^\r\n] means in other word neither of those ... so if
        either is present then the pattern comes to an end.
      • Axel Berger
        ... r and n are quite specific and denote the precise bytes or characters $13 and $10. R stands for any recognizable newline combination . I ve only used
        Message 3 of 13 , Dec 27, 2011
          joy8388608 wrote:
          > While we're at it, can someone explain the difference between
          > \R vrs \r\n? I know enough to try both when having trouble but
          > am not clear on the difference.

          \r and \n are quite specific and denote the precise bytes or characters
          $13 and $10. \R stands for "any recognizable newline combination". I've
          only used \R in the search string so far and don't know offhand, if it
          can be used in the replace one.

          One funy thing that no one else seems able to reproduce: Writing "\r\n"
          in a replace string sometimes leads to two new lines being produced.
          I've taken to always wrting just "\n" and that works fine. I've no idea
          why that should be, it oughn't and doesn't for anyone else, but such is
          life.

          Axel
        • John Shotsky
          Thank you, I was wondering how to do that. I wrote a separate clip line to eliminate the Title:: in the new doc, but I ll tweak it as you show. The answer for
          Message 4 of 13 , Dec 27, 2011
            Thank you, I was wondering how to do that. I wrote a separate clip line to eliminate the Title:: in the new doc, but
            I'll tweak it as you show.

            The answer for \R was already provided, but in short, \R means 'any kind of crlf combination, meaning Mac, *nix and
            Windows formats are all accommodated as a CRLF. But in a negative class, you need both because classes are
            'character-specific', so you need both the \r and the \n in order to avoid gobbling one and not the other.

            Regards,
            John
            RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of joy8388608
            Sent: Tuesday, December 27, 2011 07:30
            To: ntb-clips@yahoogroups.com
            Subject: Re: [Clip] Collecting a list from a document




            --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
            >
            > Thanks. I got it working with the following:
            >
            > ^!Jump 1
            > ^!SetListDelimiter ^p
            > ^!SetClipboard ^$GetDocMatchAll("(?s)^Title::[^\r\n]+")$
            > ^!TOOLBAR New Document
            > ^!TOOLBAR Paste
            > ^!Save As titles.txt
            >
            > Regards,
            > John

            If you replace the third line with the following
            ^!SetClipboard ^$GetDocMatchAll("(?s)(^Title::)([^\r\n]+)";2)$
            your results will leave out the Title:: that precedes each line.

            While we're at it, can someone explain the difference between \R vrs \r\n? I know enough to try both when having trouble
            but am not clear on the difference.

            Joy



            [Non-text portions of this message have been removed]
          • Don
            ... You can easily then make that insert anchor links in an html document (I think that is what Alex was doing), or even make these into bookmarks like the
            Message 5 of 13 , Dec 27, 2011
              On 12/27/2011 8:26 AM, John Shotsky wrote:
              > ^!Jump 1
              > ^!SetListDelimiter ^p
              > ^!SetClipboard ^$GetDocMatchAll("(?s)^Title::[^\r\n]+")$
              > ^!TOOLBAR New Document
              > ^!TOOLBAR Paste
              > ^!Save As titles.txt

              You can easily then make that insert anchor links in an html document (I
              think that is what Alex was doing), or even make these into bookmarks
              like the other poster was doing in his project because in this piece
              each of these are unique.

              I've decided to make a "title jump" clip as a demonstration (now that I
              realize how to build a wizard on the fly -- forgot if I knew before).

              So here it is:
              :JumpToTitleClip
              ;by don at htmlfixit dot com
              ;using many thoughts of others!

              :StartUP
              ;figure out if bookmarks already set and if yes, jump to GenerateList
              ^!If "^%bookmarks%" <> "" GenerateList

              :CreateBookmarks
              ;create bookmarks if not already set
              ^!Set %bookmarks%=""
              ^!Jump Doc_Start
              ^!SetListDelimiter |
              ;get the titles without Title:: per suggestion in list
              ^!Set %bookmarkchoices%="^$GetDocMatchAll("(?s)(^Title::)([^\r\n]+)";2)$"
              ;by using append the wizard is not executed in real time
              ^!Append %bookmarks%="^?{(T=C)Choose a value==^%bookmarkchoices%}"

              :GenerateList
              ;offer choice of bookmarks
              ;note that the variable bookmarks in the wizard we set above with append
              ^!Set %goGetIt%="^%bookmarks%"
              ^!Find "^%goGetIt%" CWS
              ^!ClearVariable %goGetIt%
              ;line 25 including blanks/comments above -- look for long lines if not true
            • John Shotsky
              R in the replace string will give you an R. In the replace string, you need r n (both), because there are some oddball circumstances where n by itself will
              Message 6 of 13 , Dec 27, 2011
                \R in the replace string will give you an R. In the replace string, you need \r\n (both), because there are some
                oddball circumstances where \n by itself will cause errors. My whole clip library originally used only \n in replaces,
                but I had to replace them all with \r\n to avoid edge cases.

                \r\n by itself will not produce two lines in any form that I have ever seen. When I want a blank line, I use \r\n\r\n. I
                process documents with thousands of lines every day, and get not one error, ever. One explanation of why that might be
                happening is that not all \r\n are 'standardized' at the beginning of a clip library. One of my first clips replaces \R
                with \r\n, so that I am positive all are the same from that point on.

                Regards,
                John
                RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                Sent: Tuesday, December 27, 2011 07:48
                To: ntb-clips@yahoogroups.com
                Subject: Re: [Clip] Collecting a list from a document


                joy8388608 wrote:
                > While we're at it, can someone explain the difference between
                > \R vrs \r\n? I know enough to try both when having trouble but
                > am not clear on the difference.

                \r and \n are quite specific and denote the precise bytes or characters
                $13 and $10. \R stands for "any recognizable newline combination". I've
                only used \R in the search string so far and don't know offhand, if it
                can be used in the replace one.

                One funy thing that no one else seems able to reproduce: Writing "\r\n"
                in a replace string sometimes leads to two new lines being produced.
                I've taken to always wrting just "\n" and that works fine. I've no idea
                why that should be, it oughn't and doesn't for anyone else, but such is
                life.

                Axel



                [Non-text portions of this message have been removed]
              • Don
                ... Okay that misfired on second rendition requiring two iterations to get ... ;by don at htmlfixit dot com ;using many thoughts of others! ... ;create
                Message 7 of 13 , Dec 27, 2011
                  On 12/27/2011 10:51 AM, Don wrote:
                  > I've decided to make a "title jump" clip as a demonstration (now that I
                  > realize how to build a wizard on the fly -- forgot if I knew before).
                  >
                  > So here it is:

                  Okay that misfired on second rendition requiring two iterations to get
                  to title -- I think because I already assigned ... so better:
                  :JumpToTitleClip
                  ;by don at htmlfixit dot com
                  ;using many thoughts of others!

                  :CreateBookmarks
                  ;create bookmarks
                  ^!Set %bookmarks%=""
                  ^!Jump Doc_Start
                  ^!SetListDelimiter |
                  ;get the titles without Title:: per suggestion in list
                  ^!Set %bookmarkchoices%="^$GetDocMatchAll("(?s)(^Title::)([^\r\n]+)";2)$"
                  ;by using append the wizard is not executed in real time
                  ^!Append %bookmarks%="^?{(T=C)Choose a value==^%bookmarkchoices%}"

                  :GenerateList
                  ;offer choice of bookmarks
                  ;note that the variable bookmarks in the wizard we set above with append
                  ^!Set %goGetIt%="^%bookmarks%"
                  ^!Find "^%goGetIt%" CWS
                  ^!ClearVariable %goGetIt%
                  ;line 21 including blanks/comments above -- look for long lines if not true
                • John Shotsky
                  Don, you read my mind. That s what I was going to do next. I already create an html file with recipes all in sequence. The following link shows what I m doing
                  Message 8 of 13 , Dec 27, 2011
                    Don, you read my mind. That's what I was going to do next. I already create an html file with recipes all in sequence.
                    The following link shows what I'm doing with these:
                    http://recipetools.gotdns.com/index_mag.htm

                    My thought is to create an index at the start and provide links to each separate recipe. I will play around with this �
                    it sounds exactly like what I need.

                    Regards,
                    John
                    RecipeTools Web Site: http://recipetools.gotdns.com/

                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Don
                    Sent: Tuesday, December 27, 2011 07:59
                    To: ntb-clips@yahoogroups.com
                    Subject: Re: [Clip] Collecting a list from a document


                    On 12/27/2011 10:51 AM, Don wrote:
                    > I've decided to make a "title jump" clip as a demonstration (now that I
                    > realize how to build a wizard on the fly -- forgot if I knew before).
                    >
                    > So here it is:

                    Okay that misfired on second rendition requiring two iterations to get
                    to title -- I think because I already assigned ... so better:
                    :JumpToTitleClip
                    ;by don at htmlfixit dot com
                    ;using many thoughts of others!

                    :CreateBookmarks
                    ;create bookmarks
                    ^!Set %bookmarks%=""
                    ^!Jump Doc_Start
                    ^!SetListDelimiter |
                    ;get the titles without Title:: per suggestion in list
                    ^!Set %bookmarkchoices%="^$GetDocMatchAll("(?s)(^Title::)([^\r\n]+)";2)$"
                    ;by using append the wizard is not executed in real time
                    ^!Append %bookmarks%="^?{(T=C)Choose a value==^%bookmarkchoices%}"

                    :GenerateList
                    ;offer choice of bookmarks
                    ;note that the variable bookmarks in the wizard we set above with append
                    ^!Set %goGetIt%="^%bookmarks%"
                    ^!Find "^%goGetIt%" CWS
                    ^!ClearVariable %goGetIt%
                    ;line 21 including blanks/comments above -- look for long lines if not true



                    [Non-text portions of this message have been removed]
                  • Don
                    ... Mine just jumps in the text doc. in this case. You can easily build out html for jump links with an index at the top.
                    Message 9 of 13 , Dec 27, 2011
                      On 12/27/2011 11:11 AM, John Shotsky wrote:
                      > Don, you read my mind. That's what I was going to do next. I already create an html file with recipes all in sequence.
                      > The following link shows what I'm doing with these:
                      > http://recipetools.gotdns.com/index_mag.htm
                      >
                      > My thought is to create an index at the start and provide links to each separate recipe. I will play around with this –
                      > it sounds exactly like what I need.
                      >
                      > Regards,
                      > John

                      Mine just jumps in the text doc. in this case.

                      You can easily build out html for jump links with an index at the top.
                    • Don Daugherty
                      ... I realize its more typing than r n or n, but I use ^%NL% in the replace string.
                      Message 10 of 13 , Jan 17, 2012
                        On 12/27/2011 9:55 AM, John Shotsky wrote:
                        > \R in the replace string will give you an R. In the replace string, you need \r\n (both), because there are some
                        > oddball circumstances where \n by itself will cause errors. My whole clip library originally used only \n in replaces,
                        > but I had to replace them all with \r\n to avoid edge cases.
                        >
                        I realize its more typing than \r\n or \n, but I use ^%NL% in the
                        replace string.
                      Your message has been successfully submitted and would be delivered to recipients shortly.