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

REGEX Search Backward

Expand Messages
  • nullclip
    I am new to REGEX searchs. I attempted a REGEX search backwards in an outline topic for any URL, but got a could not find, start at the beginning standard
    Message 1 of 25 , Nov 1, 2013
    • 0 Attachment

      I am new to REGEX searchs.

       

      I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

       

      Is this an issue with REGEX?  Any ideas?

    • John Shotsky
      One way to do that is to start your search with (?s) A, which is the beginning of the document. Then, the item you are looking for, then the last item that you
      Message 2 of 25 , Nov 1, 2013
      • 0 Attachment

        One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

         

        Regards,
        John
        RecipeTools Web Site: http://recipetools.gotdns.com/
        John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

         

        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
        Sent: Friday, November 01, 2013 09:04
        To: ntb-clips@yahoogroups.com
        Subject: [Clip] REGEX Search Backward

         

         

        I am new to REGEX searchs.

         

        I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

         

        Is this an issue with REGEX?  Any ideas?

      • Don
        Regex only works in one direction. Forward. So I guess it is an issue with RegEx ...
        Message 3 of 25 , Nov 1, 2013
        • 0 Attachment
          Regex only works in one direction. Forward. So I guess it is an issue
          with RegEx ...

          On 11/1/2013 12:03 PM, nullclip@... wrote:
          >
          > I am new to REGEX searchs.
          >
          > I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message. The search works great forward. The outline topic has many URLs in it.
          >
          > Is this an issue with REGEX? Any ideas?
          >
        • paul_ccr
          Hi John I m new(ish) to this group and have a question about your post - the (?s) A is something that I have been looking for for a while (as a way to identify
          Message 4 of 25 , Nov 1, 2013
          • 0 Attachment
            Hi John

            I'm new(ish) to this group and have a question about your post - the (?s)\A is something that I have been looking for for a while (as a way to identify the beginning of the file). Could you explain to me what the (?s) does? I tried this as straight \A and it doesn't work so clearly the (?s) is necessary.

            Sorry if this seems a dumb question

            Best

            Paul 



            ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

            One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

             

            Regards,
            John
            RecipeTools Web Site: http://recipetools.gotdns.com/
            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

             

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
            Sent: Friday, November 01, 2013 09:04
            To: ntb-clips@yahoogroups.com
            Subject: [Clip] REGEX Search Backward

             

             

            I am new to REGEX searchs.

             

            I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

             

            Is this an issue with REGEX?  Any ideas?

          • Axel Berger
            ... Thanks, John. So far I was able to circumvent the need, but should it arise this is a perfect workaround I hadn t thought of. Danke Axel
            Message 5 of 25 , Nov 1, 2013
            • 0 Attachment
              John Shotsky wrote:
              >start your search with (?s)\A

              Thanks, John. So far I was able to circumvent the need, but should it
              arise this is a perfect workaround I hadn't thought of.

              Danke
              Axel
            • nullclip
              Thanks. You are probably correct. However, your point is not intuitive to a novice REGEX guy like me. If any NTP developers are listening, then I recommend
              Message 6 of 25 , Nov 1, 2013
              • 0 Attachment

                Thanks.  You are probably correct.  However, your point is not intuitive to a novice REGEX guy like me.

                 

                If any NTP developers are listening, then I recommend they put a note in their clip help file for the Find and Replace commands that states that the R and B attributes are not compatable. 



                ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                Regex only works in one direction. Forward. So I guess it is an issue
                with RegEx ...

                On 11/1/2013 12:03 PM, nullclip@... wrote:
                >
                > I am new to REGEX searchs.
                >
                > I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message. The search works great forward. The outline topic has many URLs in it.
                >
                > Is this an issue with REGEX? Any ideas?
                >
              • John Shotsky
                There are no dumb questions - if one doesn t know, they don t know. The (?s) tells regex to ignore line ends. Regular replaces reach only to the end of the
                Message 7 of 25 , Nov 1, 2013
                • 0 Attachment

                  There are no dumb questions - if one doesn't know, they don't know. The (?s) tells regex to ignore line ends. Regular replaces reach only to the end of the line, but if you want something in the middle of the file, you are clearly going to have to accept line ends, thus you start the line with (?s). Be careful with this, or you will be changing things far from what you intend to change.

                   

                  Regards,
                  John
                  RecipeTools Web Site: http://recipetools.gotdns.com/
                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                   

                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of lls01pat@...
                  Sent: Friday, November 01, 2013 10:31
                  To: ntb-clips@yahoogroups.com
                  Subject: RE: RE: [Clip] REGEX Search Backward

                   

                   

                  Hi John

                  I'm new(ish) to this group and have a question about your post - the (?s)\A is something that I have been looking for for a while (as a way to identify the beginning of the file). Could you explain to me what the (?s) does? I tried this as straight \A and it doesn't work so clearly the (?s) is necessary.

                  Sorry if this seems a dumb question

                  Best

                  Paul 



                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                  One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                   

                  Regards,
                  John
                  RecipeTools Web Site: http://recipetools.gotdns.com/
                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                   

                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                  Sent: Friday, November 01, 2013 09:04
                  To: ntb-clips@yahoogroups.com
                  Subject: [Clip] REGEX Search Backward

                   

                   

                  I am new to REGEX searchs.

                   

                  I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                   

                  Is this an issue with REGEX?  Any ideas?

                • nullclip
                  OK John. I do not understand how to use your suggestion. Perhaps you can provide an example. Here is what I attempted to do from the bottom of my outline
                  Message 8 of 25 , Nov 1, 2013
                  • 0 Attachment

                    OK John.


                    I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:


                    ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                    ; Options:

                    ;   R: Specifies that the search criteria represents a regular expression.

                    ;   I: Ignores character case.

                    ;   O: Only searches in current outline topic.

                    ;   S: Silent search. NoteTab will not display any message box.

                    ;   B: Searches backwards.


                    How would you rewrite the Find command?

                    My objective is to find the last URL in the topic.

                     



                    ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                    One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                     

                    Regards,
                    John
                    RecipeTools Web Site: http://recipetools.gotdns.com/
                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                     

                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                    Sent: Friday, November 01, 2013 09:04
                    To: ntb-clips@yahoogroups.com
                    Subject: [Clip] REGEX Search Backward

                     

                     

                    I am new to REGEX searchs.

                     

                    I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                     

                    Is this an issue with REGEX?  Any ideas?

                  • John Shotsky
                    Because regex is naturally greedy , it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you
                    Message 9 of 25 , Nov 1, 2013
                    • 0 Attachment

                      Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                       

                      So:

                      ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                      should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                       

                      I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                      Regards,
                      John
                      RecipeTools Web Site: http://recipetools.gotdns.com/
                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                       

                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                      Sent: Friday, November 01, 2013 15:57
                      To: ntb-clips@yahoogroups.com
                      Subject: RE: RE: [Clip] REGEX Search Backward

                       

                       

                      OK John.

                       

                      I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                       

                      ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                      ; Options:

                      ;   R: Specifies that the search criteria represents a regular expression.

                      ;   I: Ignores character case.

                      ;   O: Only searches in current outline topic.

                      ;   S: Silent search. NoteTab will not display any message box.

                      ;   B: Searches backwards.

                       

                      How would you rewrite the Find command?

                       

                      My objective is to find the last URL in the topic.

                       

                       



                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                      One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                       

                      Regards,
                      John
                      RecipeTools Web Site: http://recipetools.gotdns.com/
                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                       

                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                      Sent: Friday, November 01, 2013 09:04
                      To: ntb-clips@yahoogroups.com
                      Subject: [Clip] REGEX Search Backward

                       

                       

                      I am new to REGEX searchs.

                       

                      I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                       

                      Is this an issue with REGEX?  Any ideas?

                    • nullclip
                      That worked, but only if I started my search anywhere above the last instance of a URL in the text. A search for (?s) A did not find the top of the text like I
                      Message 10 of 25 , Nov 1, 2013
                      • 0 Attachment

                        That worked, but only if I started my search anywhere above the last instance of a URL in the text.


                        A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria?


                        The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.


                        How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                        ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                        Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                         

                        So:

                        ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                        should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                         

                        I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                        Regards,
                        John
                        RecipeTools Web Site: http://recipetools.gotdns.com/
                        John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                         

                        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                        Sent: Friday, November 01, 2013 15:57
                        To: ntb-clips@yahoogroups.com
                        Subject: RE: RE: [Clip] REGEX Search Backward

                         

                         

                        OK John.

                         

                        I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                         

                        ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                        ; Options:

                        ;   R: Specifies that the search criteria represents a regular expression.

                        ;   I: Ignores character case.

                        ;   O: Only searches in current outline topic.

                        ;   S: Silent search. NoteTab will not display any message box.

                        ;   B: Searches backwards.

                         

                        How would you rewrite the Find command?

                         

                        My objective is to find the last URL in the topic.

                         

                         



                        ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                        One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                         

                        Regards,
                        John
                        RecipeTools Web Site: http://recipetools.gotdns.com/
                        John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                         

                        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                        Sent: Friday, November 01, 2013 09:04
                        To: ntb-clips@yahoogroups.com
                        Subject: [Clip] REGEX Search Backward

                         

                         

                        I am new to REGEX searchs.

                         

                        I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                         

                        Is this an issue with REGEX?  Any ideas?

                      • John Shotsky
                        Greed and K are not related, the K only defines the start of the capture section. Oh, wait! I didn t specify the A, and that s why it didn t work. Duh.
                        Message 11 of 25 , Nov 1, 2013
                        • 0 Attachment

                          Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                          ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                          A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                           

                          Regards,
                          John
                          RecipeTools Web Site: http://recipetools.gotdns.com/
                          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                           

                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                          Sent: Friday, November 01, 2013 18:36
                          To: ntb-clips@yahoogroups.com
                          Subject: RE: RE: RE: [Clip] REGEX Search Backward

                           

                           

                          That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                           

                          A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                           

                          The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                           

                          How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                          ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                          Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                           

                          So:

                          ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                          should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                           

                          I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                          Regards,
                          John
                          RecipeTools Web Site: http://recipetools.gotdns.com/
                          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                           

                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                          Sent: Friday, November 01, 2013 15:57
                          To: ntb-clips@yahoogroups.com
                          Subject: RE: RE: [Clip] REGEX Search Backward

                           

                           

                          OK John.

                           

                          I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                           

                          ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                          ; Options:

                          ;   R: Specifies that the search criteria represents a regular expression.

                          ;   I: Ignores character case.

                          ;   O: Only searches in current outline topic.

                          ;   S: Silent search. NoteTab will not display any message box.

                          ;   B: Searches backwards.

                           

                          How would you rewrite the Find command?

                           

                          My objective is to find the last URL in the topic.

                           

                           



                          ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                          One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                           

                          Regards,
                          John
                          RecipeTools Web Site: http://recipetools.gotdns.com/
                          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                           

                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                          Sent: Friday, November 01, 2013 09:04
                          To: ntb-clips@yahoogroups.com
                          Subject: [Clip] REGEX Search Backward

                           

                           

                          I am new to REGEX searchs.

                           

                          I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                           

                          Is this an issue with REGEX?  Any ideas?

                        • nullclip
                          Don t beat yourself up. You are the alpha smart guy here. I tried your latest regex, and it worked, but only if I began the search from the start of the text.
                          Message 12 of 25 , Nov 2, 2013
                          • 0 Attachment

                            Don't beat yourself up.  You are the alpha smart guy here.


                            I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?


                            I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                            ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                            Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                            ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                            A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                             

                            Regards,
                            John
                            RecipeTools Web Site: http://recipetools.gotdns.com/
                            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                             

                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                            Sent: Friday, November 01, 2013 18:36
                            To: ntb-clips@yahoogroups.com
                            Subject: RE: RE: RE: [Clip] REGEX Search Backward

                             

                             

                            That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                             

                            A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                             

                            The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                             

                            How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                            ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                            Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                             

                            So:

                            ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                            should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                             

                            I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                            Regards,
                            John
                            RecipeTools Web Site: http://recipetools.gotdns.com/
                            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                             

                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                            Sent: Friday, November 01, 2013 15:57
                            To: ntb-clips@yahoogroups.com
                            Subject: RE: RE: [Clip] REGEX Search Backward

                             

                             

                            OK John.

                             

                            I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                             

                            ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                            ; Options:

                            ;   R: Specifies that the search criteria represents a regular expression.

                            ;   I: Ignores character case.

                            ;   O: Only searches in current outline topic.

                            ;   S: Silent search. NoteTab will not display any message box.

                            ;   B: Searches backwards.

                             

                            How would you rewrite the Find command?

                             

                            My objective is to find the last URL in the topic.

                             

                             



                            ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                            One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                             

                            Regards,
                            John
                            RecipeTools Web Site: http://recipetools.gotdns.com/
                            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                             

                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                            Sent: Friday, November 01, 2013 09:04
                            To: ntb-clips@yahoogroups.com
                            Subject: [Clip] REGEX Search Backward

                             

                             

                            I am new to REGEX searchs.

                             

                            I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                             

                            Is this an issue with REGEX?  Any ideas?

                          • John Shotsky
                            No, it should start from the beginning. I haven t worked with outlines before, perhaps that is involved. I could test it if I had a sample to work with. You
                            Message 13 of 25 , Nov 2, 2013
                            • 0 Attachment

                              No, it should start from the beginning. I haven't worked with outlines before, perhaps that is involved. I could test it if I had a sample to work with. You could send me a small sample privately, if you want.

                               

                              Regards,
                              John
                              RecipeTools Web Site: http://recipetools.gotdns.com/
                              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                               

                              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                              Sent: Saturday, November 02, 2013 05:52
                              To: ntb-clips@yahoogroups.com
                              Subject: RE: RE: RE: RE: [Clip] REGEX Search Backward

                               

                               

                              Don't beat yourself up.  You are the alpha smart guy here.

                               

                              I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?

                               

                              I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                              ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                              Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                              ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                              A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                               

                              Regards,
                              John
                              RecipeTools Web Site: http://recipetools.gotdns.com/
                              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                               

                              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                              Sent: Friday, November 01, 2013 18:36
                              To: ntb-clips@yahoogroups.com
                              Subject: RE: RE: RE: [Clip] REGEX Search Backward

                               

                               

                              That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                               

                              A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                               

                              The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                               

                              How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                              ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                              Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                               

                              So:

                              ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                              should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                               

                              I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                              Regards,
                              John
                              RecipeTools Web Site: http://recipetools.gotdns.com/
                              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                               

                              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                              Sent: Friday, November 01, 2013 15:57
                              To: ntb-clips@yahoogroups.com
                              Subject: RE: RE: [Clip] REGEX Search Backward

                               

                               

                              OK John.

                               

                              I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                               

                              ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                              ; Options:

                              ;   R: Specifies that the search criteria represents a regular expression.

                              ;   I: Ignores character case.

                              ;   O: Only searches in current outline topic.

                              ;   S: Silent search. NoteTab will not display any message box.

                              ;   B: Searches backwards.

                               

                              How would you rewrite the Find command?

                               

                              My objective is to find the last URL in the topic.

                               

                               



                              ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                              One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                               

                              Regards,
                              John
                              RecipeTools Web Site: http://recipetools.gotdns.com/
                              John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                               

                              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                              Sent: Friday, November 01, 2013 09:04
                              To: ntb-clips@yahoogroups.com
                              Subject: [Clip] REGEX Search Backward

                               

                               

                              I am new to REGEX searchs.

                               

                              I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                               

                              Is this an issue with REGEX?  Any ideas?

                            • John Shotsky
                              I tested on a regular document, and the following worked to capture the last URL. ^!Find (?s) A.+ Khttps?://[^ x20 r n ]+ AIORSW Note the change in options.
                              Message 14 of 25 , Nov 2, 2013
                              • 0 Attachment

                                I tested on a regular document, and the following worked to capture the last URL.

                                ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" AIORSW

                                Note the change in options. It repeatedly captures the last url regardless of where in the document the cursor is positioned. Note that if you have any html in your document, you should put a double quote in your negative class to prevent capturing trailing double quotes that are not part of the url.

                                 

                                Regards,
                                John
                                RecipeTools Web Site: http://recipetools.gotdns.com/
                                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                 

                                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                Sent: Saturday, November 02, 2013 05:52
                                To: ntb-clips@yahoogroups.com
                                Subject: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                 

                                 

                                Don't beat yourself up.  You are the alpha smart guy here.

                                 

                                I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?

                                 

                                I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                                ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                                ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                                A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                                 

                                Regards,
                                John
                                RecipeTools Web Site: http://recipetools.gotdns.com/
                                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                 

                                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                Sent: Friday, November 01, 2013 18:36
                                To: ntb-clips@yahoogroups.com
                                Subject: RE: RE: RE: [Clip] REGEX Search Backward

                                 

                                 

                                That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                                 

                                A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                                 

                                The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                                 

                                How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                                ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                                 

                                So:

                                ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                                should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                                 

                                I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                                Regards,
                                John
                                RecipeTools Web Site: http://recipetools.gotdns.com/
                                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                 

                                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                Sent: Friday, November 01, 2013 15:57
                                To: ntb-clips@yahoogroups.com
                                Subject: RE: RE: [Clip] REGEX Search Backward

                                 

                                 

                                OK John.

                                 

                                I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                                 

                                ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                                ; Options:

                                ;   R: Specifies that the search criteria represents a regular expression.

                                ;   I: Ignores character case.

                                ;   O: Only searches in current outline topic.

                                ;   S: Silent search. NoteTab will not display any message box.

                                ;   B: Searches backwards.

                                 

                                How would you rewrite the Find command?

                                 

                                My objective is to find the last URL in the topic.

                                 

                                 



                                ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                                 

                                Regards,
                                John
                                RecipeTools Web Site: http://recipetools.gotdns.com/
                                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                 

                                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                Sent: Friday, November 01, 2013 09:04
                                To: ntb-clips@yahoogroups.com
                                Subject: [Clip] REGEX Search Backward

                                 

                                 

                                I am new to REGEX searchs.

                                 

                                I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                                 

                                Is this an issue with REGEX?  Any ideas?

                              • nullclip
                                I investigated the problem and discovered the following: - The use of A and/or W options had no impact on the Find command in this application. - If I placed
                                Message 15 of 25 , Nov 2, 2013
                                • 0 Attachment

                                  I investigated the problem and discovered the following:


                                  - The use of A and/or W options had no impact on the Find command in this application.


                                  - If I placed my cursor in the middle of any URL in the text, then the search would not work.  No change in the document or error message resulted.


                                  - If I placed my cursor at the start of the last URL in the text, then the search would not work.  No change in the document or error message resulted.


                                  - If I placed my cursor anywhere after the last URL in the text, then the search would not work.  No change in the document or error message resulted.


                                  - If I placed my cursor anywhere in the text other than in any URL or at the start of the last URL or after the last URL, then the search worked.


                                  - The above is true for both document and outline text.


                                  Strange behavior.


                                  Your note that excludes a " from the search is good.  Some URLs begin simply www...  How should I modify the regex criteria to account for them also?



                                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                  I tested on a regular document, and the following worked to capture the last URL.

                                  ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" AIORSW

                                  Note the change in options. It repeatedly captures the last url regardless of where in the document the cursor is positioned. Note that if you have any html in your document, you should put a double quote in your negative class to prevent capturing trailing double quotes that are not part of the url.

                                   

                                  Regards,
                                  John
                                  RecipeTools Web Site: http://recipetools.gotdns.com/
                                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                   

                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                  Sent: Saturday, November 02, 2013 05:52
                                  To: ntb-clips@yahoogroups.com
                                  Subject: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                   

                                   

                                  Don't beat yourself up.  You are the alpha smart guy here.

                                   

                                  I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?

                                   

                                  I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                  Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                                  ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                                  A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                                   

                                  Regards,
                                  John
                                  RecipeTools Web Site: http://recipetools.gotdns.com/
                                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                   

                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                  Sent: Friday, November 01, 2013 18:36
                                  To: ntb-clips@yahoogroups.com
                                  Subject: RE: RE: RE: [Clip] REGEX Search Backward

                                   

                                   

                                  That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                                   

                                  A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                                   

                                  The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                                   

                                  How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                  Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                                   

                                  So:

                                  ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                                  should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                                   

                                  I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                                  Regards,
                                  John
                                  RecipeTools Web Site: http://recipetools.gotdns.com/
                                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                   

                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                  Sent: Friday, November 01, 2013 15:57
                                  To: ntb-clips@yahoogroups.com
                                  Subject: RE: RE: [Clip] REGEX Search Backward

                                   

                                   

                                  OK John.

                                   

                                  I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                                   

                                  ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                                  ; Options:

                                  ;   R: Specifies that the search criteria represents a regular expression.

                                  ;   I: Ignores character case.

                                  ;   O: Only searches in current outline topic.

                                  ;   S: Silent search. NoteTab will not display any message box.

                                  ;   B: Searches backwards.

                                   

                                  How would you rewrite the Find command?

                                   

                                  My objective is to find the last URL in the topic.

                                   

                                   



                                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                  One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last item that you are looking 'backwards' from. This is still a search down, only you have anchored it to start at the beginning of the doc and search down to your final term.

                                   

                                  Regards,
                                  John
                                  RecipeTools Web Site: http://recipetools.gotdns.com/
                                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                   

                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                  Sent: Friday, November 01, 2013 09:04
                                  To: ntb-clips@yahoogroups.com
                                  Subject: [Clip] REGEX Search Backward

                                   

                                   

                                  I am new to REGEX searchs.

                                   

                                  I attempted a REGEX search backwards in an outline topic for any URL, but got a 'could not find, start at the beginning' standard message.  The search works great forward.  The outline topic has many URLs in it.

                                   

                                  Is this an issue with REGEX?  Any ideas?

                                • John Shotsky
                                  ^!Find (?s) A.+ K(https?://|www .)[^ x20 r n ]+ AIORSW There may be problems with this, because it may ignore the http section if the www section is
                                  Message 16 of 25 , Nov 2, 2013
                                  • 0 Attachment

                                    ^!Find "(?s)\A.+\K(https?://|www\.)[^\x20\r\n<>]+" AIORSW

                                    There may be problems with this, because it may ignore the http section if the www section is present.

                                    I don't know why it doesn't work for you. Try it in a non-outline document, where it works for me every time.

                                     

                                    Regards,
                                    John
                                    RecipeTools Web Site: http://recipetools.gotdns.com/
                                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                     

                                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                    Sent: Saturday, November 02, 2013 07:53
                                    To: ntb-clips@yahoogroups.com
                                    Subject: RE: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                     

                                     

                                    I investigated the problem and discovered the following:

                                     

                                    - The use of A and/or W options had no impact on the Find command in this application.

                                     

                                    - If I placed my cursor in the middle of any URL in the text, then the search would not work.  No change in the document or error message resulted.

                                     

                                    - If I placed my cursor at the start of the last URL in the text, then the search would not work.  No change in the document or error message resulted.

                                     

                                    - If I placed my cursor anywhere after the last URL in the text, then the search would not work.  No change in the document or error message resulted.

                                     

                                    - If I placed my cursor anywhere in the text other than in any URL or at the start of the last URL or after the last URL, then the search worked.

                                     

                                    - The above is true for both document and outline text.

                                     

                                    Strange behavior.

                                     

                                    Your note that excludes a " from the search is good.  Some URLs begin simply www...  How should I modify the regex criteria to account for them also?



                                    ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                    I tested on a regular document, and the following worked to capture the last URL.

                                    ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" AIORSW

                                    Note the change in options. It repeatedly captures the last url regardless of where in the document the cursor is positioned. Note that if you have any html in your document, you should put a double quote in your negative class to prevent capturing trailing double quotes that are not part of the url.

                                     

                                    Regards,
                                    John
                                    RecipeTools Web Site: http://recipetools.gotdns.com/
                                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                     

                                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                    Sent: Saturday, November 02, 2013 05:52
                                    To: ntb-clips@yahoogroups.com
                                    Subject: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                     

                                     

                                    Don't beat yourself up.  You are the alpha smart guy here.

                                     

                                    I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?

                                     

                                    I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                                    ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                    Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                                    ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                                    A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                                     

                                    Regards,
                                    John
                                    RecipeTools Web Site: http://recipetools.gotdns.com/
                                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                     

                                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                    Sent: Friday, November 01, 2013 18:36
                                    To: ntb-clips@yahoogroups.com
                                    Subject: RE: RE: RE: [Clip] REGEX Search Backward

                                     

                                     

                                    That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                                     

                                    A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                                     

                                    The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                                     

                                    How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                                    ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                    Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                                     

                                    So:

                                    ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                                    should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                                     

                                    I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                                    Regards,
                                    John
                                    RecipeTools Web Site: http://recipetools.gotdns.com/
                                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                     

                                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                    Sent: Friday, November 01, 2013 15:57
                                    To: ntb-clips@yahoogroups.com
                                    Subject: RE: RE: [Clip] REGEX Search Backward

                                     

                                     

                                    OK John.

                                     

                                    I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                                     

                                    ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                                    ; Options:

                                    ;   R: Specifies that the search criteria represents a regular expression.

                                    ;   I: Ignores character case.

                                    ;   O: Only searches in current outline topic.

                                    ;   S: Silent search. NoteTab will not display any message box.

                                    ;   B: Searches backwards.

                                     

                                    How would you rewrite the Find command?

                                     

                                    My objective is to find the last URL in the topic.

                                     

                                     



                                    ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                    One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last

                                    (Message over 64 KB, truncated)

                                  • nullclip
                                    The strange behavior is identical in both documents and outline topics. I can work around the strange behavior, but it seems odd none the less. The
                                    Message 17 of 25 , Nov 2, 2013
                                    • 0 Attachment

                                      The strange behavior is identical in both documents and outline topics.


                                      I can work around the strange behavior, but it seems odd none the less.  The work-around is to put the cursor at the start of the document or outline topic's text before beginning the search for the last URL.



                                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                      ^!Find "(?s)\A.+\K(https?://|www\.)[^\x20\r\n<>]+" AIORSW

                                      There may be problems with this, because it may ignore the http section if the www section is present.

                                      I don't know why it doesn't work for you. Try it in a non-outline document, where it works for me every time.

                                       

                                      Regards,
                                      John
                                      RecipeTools Web Site: http://recipetools.gotdns.com/
                                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                       

                                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                      Sent: Saturday, November 02, 2013 07:53
                                      To: ntb-clips@yahoogroups.com
                                      Subject: RE: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                       

                                       

                                      I investigated the problem and discovered the following:

                                       

                                      - The use of A and/or W options had no impact on the Find command in this application.

                                       

                                      - If I placed my cursor in the middle of any URL in the text, then the search would not work.  No change in the document or error message resulted.

                                       

                                      - If I placed my cursor at the start of the last URL in the text, then the search would not work.  No change in the document or error message resulted.

                                       

                                      - If I placed my cursor anywhere after the last URL in the text, then the search would not work.  No change in the document or error message resulted.

                                       

                                      - If I placed my cursor anywhere in the text other than in any URL or at the start of the last URL or after the last URL, then the search worked.

                                       

                                      - The above is true for both document and outline text.

                                       

                                      Strange behavior.

                                       

                                      Your note that excludes a " from the search is good.  Some URLs begin simply www...  How should I modify the regex criteria to account for them also?



                                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                      I tested on a regular document, and the following worked to capture the last URL.

                                      ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" AIORSW

                                      Note the change in options. It repeatedly captures the last url regardless of where in the document the cursor is positioned. Note that if you have any html in your document, you should put a double quote in your negative class to prevent capturing trailing double quotes that are not part of the url.

                                       

                                      Regards,
                                      John
                                      RecipeTools Web Site: http://recipetools.gotdns.com/
                                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                       

                                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                      Sent: Saturday, November 02, 2013 05:52
                                      To: ntb-clips@yahoogroups.com
                                      Subject: RE: RE: RE: RE: [Clip] REGEX Search Backward

                                       

                                       

                                      Don't beat yourself up.  You are the alpha smart guy here.

                                       

                                      I tried your latest regex, and it worked, but only if I began the search from the start of the text.  Is that what you intended?

                                       

                                      I suppose it is reasonable that I cannot start the search from the end of the text, but I find it odd that I cannot start the search from anywhere before the last URL.



                                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                      Greed and \K are not related, the \K only defines the start of the capture section. Oh, wait! I didn't specify the \A, and that's why it didn't work. Duh.

                                      ^!Find "(?s)\A.+\Khttps?://[^\x20\r\n<>]+" IORS

                                      A lesson in regex - it can be pretty tricky, but it works. It is SO easy to overlook little things that make things not work as expected. I have stared at lines for a long time and not seen what is wrong - I call them dumb loops, and it happens to me far too often.

                                       

                                      Regards,
                                      John
                                      RecipeTools Web Site: http://recipetools.gotdns.com/
                                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                       

                                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                      Sent: Friday, November 01, 2013 18:36
                                      To: ntb-clips@yahoogroups.com
                                      Subject: RE: RE: RE: [Clip] REGEX Search Backward

                                       

                                       

                                      That worked, but only if I started my search anywhere above the last instance of a URL in the text.

                                       

                                      A search for (?s)\A did not find the top of the text like I thought you had indicated.  Are these regex options that must be specified before search criteria? Oh, wait - I wrote it without the \A! Dumb.

                                       

                                      The search ^!Find "https?://[^\x20\r\n<>]+" IORS finds the next instance of a URL.

                                       

                                      How does \K 'reset start of match' (defined in NTP regex help file) equate to greed?



                                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                      Because regex is naturally 'greedy', it will always go to the last instance that meets the criteria in the absence of a control to prevent that. Also, you don't need commas with the options. I have never used that 'B' option, but it is not a regex expression, it is part of the scripting language of NoteTab. The regular expression engine is from pcre and is regularly updated, while the scripting language in NoteTab is independent of pcre other than the fact that it facilitates USING regex in its programming scripts.

                                       

                                      So:

                                      ^!Find "(?s).+\Khttps?://[^\x20\r\n<>]+" IORS

                                      should work. That first .+ tells it to gather everything up to finding the term of interest, even if it means passing up that term multiple times. So it will find the last one. If you use an A option, it will only find the first one. (or you could use .+? to achieve the same goal). The \K says to ignore everything up to that last http. Assumes you only want to highlight/select that last URL.

                                       

                                      I have a habit of always placing my options in alphabetical order and upper case, which enables me to always find a specific set of options, knowing that they will be in only one order, regardless of how many there are.

                                      Regards,
                                      John
                                      RecipeTools Web Site: http://recipetools.gotdns.com/
                                      John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                       

                                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of nullclip@...
                                      Sent: Friday, November 01, 2013 15:57
                                      To: ntb-clips@yahoogroups.com
                                      Subject: RE: RE: [Clip] REGEX Search Backward

                                       

                                       

                                      OK John.

                                       

                                      I do not understand how to use your suggestion.  Perhaps you can provide an example.  Here is what I attempted to do from the bottom of my outline topic text, last character:

                                       

                                      ^!Find "https?://[^\x20\r\n<>]+" R,I,O,S,B

                                      ; Options:

                                      ;   R: Specifies that the search criteria represents a regular expression.

                                      ;   I: Ignores character case.

                                      ;   O: Only searches in current outline topic.

                                      ;   S: Silent search. NoteTab will not display any message box.

                                      ;   B: Searches backwards.

                                       

                                      How would you rewrite the Find command?

                                       

                                      My objective is to find the last URL in the topic.

                                       

                                       



                                      ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                      One way to do that is to start your search with (?s)\A, which is the beginning of the document. Then, the item you are looking for, then the last

                                      (Message over 64 KB, truncated)

                                    • Axel Berger
                                      ... Sorry, I can t reproduce that. So far I had only followed the thread without trying anything myself but I just ran John s clip on one of my HTMLs and it
                                      Message 18 of 25 , Nov 2, 2013
                                      • 0 Attachment
                                        nullclip@... wrote:
                                        > The work-around is to put the cursor at the start of the
                                        > document or outline topic's text before beginning the search
                                        > for the last URL.

                                        Sorry, I can't reproduce that. So far I had only followed the thread
                                        without trying anything myself but I just ran John's clip on one of my
                                        HTMLs and it worked out of the box as advertised.

                                        Two small points:
                                        As per the help file the "A" is meaningless here, it is only applicable
                                        for ^!Replace. The relevant part for finding the last occurrance is the
                                        greedy dot after the \A.
                                        A slight niggle is that the closing quotes are included while the
                                        opening ones aren't. John has already posted the correction.

                                        By the way, as the "W" makes the search start at the beginning of the
                                        file anyway and the dot doesn't look for anything specific, the \A is
                                        superfluous here.

                                        This leaves me with

                                        ^!Find "(?s).+\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                        and it doesn't matter where in the files the cursor sits to begin with.

                                        Axel
                                      • John Shotsky
                                        Thanks for the correction on the A - of course, the W option does cause it to start at the beginning. Duh again. When I want to insert something at the top of
                                        Message 19 of 25 , Nov 2, 2013
                                        • 0 Attachment

                                          Thanks for the correction on the \A - of course, the W option does cause it to start at the beginning. Duh again.

                                          When I want to insert something at the top of the document, I often use the replace \A with my intended text, which works fine and doesn't require jumping to the top first.

                                           

                                          Regards,
                                          John
                                          RecipeTools Web Site: http://recipetools.gotdns.com/
                                          John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                           

                                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                                          Sent: Saturday, November 02, 2013 09:34
                                          To: ntb-clips@yahoogroups.com
                                          Subject: Re: [Clip] REGEX Search Backward

                                           

                                           

                                          nullclip@... wrote:

                                          > The work-around is to put the cursor at the start of the
                                          > document or outline topic's text before beginning the search
                                          > for the last URL.

                                          Sorry, I can't reproduce that. So far I had only followed the thread
                                          without trying anything myself but I just ran John's clip on one of my
                                          HTMLs and it worked out of the box as advertised.

                                          Two small points:
                                          As per the help file the "A" is meaningless here, it is only applicable
                                          for ^!Replace. The relevant part for finding the last occurrance is the
                                          greedy dot after the \A.
                                          A slight niggle is that the closing quotes are included while the
                                          opening ones aren't. John has already posted the correction.

                                          By the way, as the "W" makes the search start at the beginning of the
                                          file anyway and the dot doesn't look for anything specific, the \A is
                                          superfluous here.

                                          This leaves me with

                                          ^!Find "(?s).+\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                          and it doesn't matter where in the files the cursor sits to begin with.

                                          Axel

                                        • nullclip
                                          Yes. Your regex together with the W option fixes the issues associated with start location. There remains one hassle. For example, say the following URL is
                                          Message 20 of 25 , Nov 2, 2013
                                          • 0 Attachment

                                            Yes.  Your regex together with the W option fixes the issues associated with start location.  There remains one hassle.  For example, say the following URL is the last URL in the text.


                                            http://www.logicalchess.com/


                                            The regex finds and highlights only www.logicalchess.com/ instead of the full http://www.logicalchess.com/.

                                            My objective is to find and fully highlight the last URL in a list of URLs where the URLs can start with either http or www.


                                            ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                            nullclip@... wrote:
                                            > The work-around is to put the cursor at the start of the
                                            > document or outline topic's text before beginning the search
                                            > for the last URL.

                                            Sorry, I can't reproduce that. So far I had only followed the thread
                                            without trying anything myself but I just ran John's clip on one of my
                                            HTMLs and it worked out of the box as advertised.

                                            Two small points:
                                            As per the help file the "A" is meaningless here, it is only applicable
                                            for ^!Replace. The relevant part for finding the last occurrance is the
                                            greedy dot after the \A.
                                            A slight niggle is that the closing quotes are included while the
                                            opening ones aren't. John has already posted the correction.

                                            By the way, as the "W" makes the search start at the beginning of the
                                            file anyway and the dot doesn't look for anything specific, the \A is
                                            superfluous here.

                                            This leaves me with

                                            ^!Find "(?s).+\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                            and it doesn't matter where in the files the cursor sits to begin with.

                                            Axel
                                          • Axel Berger
                                            ... Yes, John already mentioned that problem himself. If the start can be either http or www and the term before is greedy, then you ll capture as little as
                                            Message 21 of 25 , Nov 2, 2013
                                            • 0 Attachment
                                              nullclip@... wrote:
                                              > The regex finds and highlights only www.logicalchess.com/ instead of
                                              > the full http://www.logicalchess.com/.

                                              Yes, John already mentioned that problem himself. If the start can be
                                              either http or www and the term before is greedy, then you'll capture as
                                              little as possible. To solve this you have to look at what always comes
                                              directly before your string. It may be an equals (=) or a quote, if the
                                              URL is always placed in quotes. Assuming the latter I get:

                                              ^!Find "(?s).+"\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                              As you never specified what comes outside your search string, I had to
                                              guess here.

                                              Axel
                                            • John Shotsky
                                              Additionally, many URL s are enclosed in angle brackets. In order to start the capture at the beginning of the url in every case, and assuming you don t want
                                              Message 22 of 25 , Nov 3, 2013
                                              • 0 Attachment

                                                Additionally, many URL's are enclosed in angle brackets. In order to start the capture at the beginning of the url in every case, and assuming you don't want to capture the angle brackets if present, then another negative class should be added to the .+ term so that none of these things can be caught up in the greediness.

                                                ^!Find "(?s).+[^\r\n</\"][</"]*\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                                So, now the .+ can't end with <, " or /. If < or " are present, they are passed but not captured. Now, if the http is first, it will be captured, but if the www is first, it will be captured.

                                                 

                                                Regards,
                                                John
                                                RecipeTools Web Site: http://recipetools.gotdns.com/
                                                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                                 

                                                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                                                Sent: Saturday, November 02, 2013 23:58
                                                To: ntb-clips@yahoogroups.com
                                                Subject: Re: [Clip] REGEX Search Backward

                                                 

                                                 

                                                nullclip@... wrote:

                                                > The regex finds and highlights only www.logicalchess.com/ instead of
                                                > the full http://www.logicalchess.com/.

                                                Yes, John already mentioned that problem himself. If the start can be
                                                either http or www and the term before is greedy, then you'll capture as
                                                little as possible. To solve this you have to look at what always comes
                                                directly before your string. It may be an equals (=) or a quote, if the
                                                URL is always placed in quotes. Assuming the latter I get:

                                                ^!Find "(?s).+"\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                                As you never specified what comes outside your search string, I had to
                                                guess here.

                                                Axel

                                              • nullclip
                                                Axel/John, Your latest Find/regex combination hit the sweet spot. The list of URLs is a simple list without quotes or brackets. Each URL is on a separate
                                                Message 23 of 25 , Nov 3, 2013
                                                • 0 Attachment

                                                  Axel/John,


                                                  Your latest Find/regex combination hit the sweet spot.  The list of URLs is a simple list without quotes or brackets.  Each URL is on a separate line proceeded by only new-line characters.  So I created the following command line based on your ideas.


                                                  ^!Find "(?s).+\r\n\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW


                                                  I remain confused about how this works.

                                                  I understand all but the portion (?s).  (A search for ?s in the NTP regex help file finds a thousand 'is' and 'as'.  Aaaarrrggghhhh!!!)

                                                  What is the purpose of each character in (?s), and taken as a whole?

                                                  Do I need both \r and \n to get the job done?  Testing suggests that only the \n is required.

                                                  If I use both of the new-line characters, then is one or both included in the results of the search by some greedy process?

                                                  Is there a single character (^%NL%) that includes both?  Is ^%NL% recognized/legal in a regex search?

                                                  Apparently, the order of the characters before the \K matters.  \n must follow \r.  If both are required to form a new line, then why does their order matter?

                                                  Finally, is there a good searchable regex reference (web, book, help file) where I can get useful information?  For example, I cannot even search for .+ in the regex help file included with NTP.

                                                  Regex tools?


                                                  Thank you both for your expert help in sorting though all this.



                                                  ---In ntb-clips@yahoogroups.com, <ntb-clips@yahoogroups.com> wrote:

                                                  Additionally, many URL's are enclosed in angle brackets. In order to start the capture at the beginning of the url in every case, and assuming you don't want to capture the angle brackets if present, then another negative class should be added to the .+ term so that none of these things can be caught up in the greediness.

                                                  ^!Find "(?s).+[^\r\n</\"][</"]*\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                                  So, now the .+ can't end with <, " or /. If < or " are present, they are passed but not captured. Now, if the http is first, it will be captured, but if the www is first, it will be captured.

                                                   

                                                  Regards,
                                                  John
                                                  RecipeTools Web Site: http://recipetools.gotdns.com/
                                                  John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                                                   

                                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                                                  Sent: Saturday, November 02, 2013 23:58
                                                  To: ntb-clips@yahoogroups.com
                                                  Subject: Re: [Clip] REGEX Search Backward

                                                   

                                                   

                                                  nullclip@... wrote:

                                                  > The regex finds and highlights only www.logicalchess.com/ instead of
                                                  > the full http://www.logicalchess.com/.

                                                  Yes, John already mentioned that problem himself. If the start can be
                                                  either http or www and the term before is greedy, then you'll capture as
                                                  little as possible. To solve this you have to look at what always comes
                                                  directly before your string. It may be an equals (=) or a quote, if the
                                                  URL is always placed in quotes. Assuming the latter I get:

                                                  ^!Find "(?s).+"\K(https?://|www\.)[^\x20"\r\n<>]+" IORSW

                                                  As you never specified what comes outside your search string, I had to
                                                  guess here.

                                                  Axel

                                                • Axel Berger
                                                  ... You should have said, this makes things much easier: ^!Find (?s).+ R K(https?://|www .)[^ r n]+ IORSW ... Yes, it s well hidden, which is a shame as I
                                                  Message 24 of 25 , Nov 3, 2013
                                                  • 0 Attachment
                                                    nullclip@... wrote:
                                                    > Each URL is on a separate line proceeded by only new-line characters.

                                                    You should have said, this makes things much easier:

                                                    ^!Find "(?s).+\R\K(https?://|www\.)[^\r\n]+" IORSW

                                                    > I understand all but the portion (?s).

                                                    Yes, it's well hidden, which is a shame as I always forget the procise
                                                    character and have to look it up again. See "Internal Option Setting"
                                                    and "Full Stop (Period, Dot) and \N"
                                                    To summarize, the dot captures anything BUT line ends unless you assert
                                                    dotall. If you do, it captures anything INCLUDING line ends.

                                                    In your special case the much simpler

                                                    ^!Find "^.+\Z" IORSW

                                                    should do it too. In effect it says "match the last line".

                                                    Axel
                                                  • Axel Berger
                                                    ... Yes the R. It summarizes all legal line ends but does NOT work in negative classes. ... This is not a list of possible characters, like a class in square
                                                    Message 25 of 25 , Nov 3, 2013
                                                    • 0 Attachment
                                                      nullclip@... wrote:
                                                      > Is there a single character (^%NL%) that includes both?

                                                      Yes the \R. It summarizes all legal line ends but does NOT work in
                                                      negative classes.

                                                      > If both are required to form a new line, then why
                                                      > does their order matter?

                                                      This is not a list of possible characters, like a class in square
                                                      brackets, but a phrase that has to occur in that precise form, just like
                                                      http or anything else. In all systems related to DOS the two character
                                                      sequence \r\n constitutes a line end. The historical reason is that in
                                                      teletypes a carriage return (to the left edge) and a line feed are two
                                                      distinct mechanical processes and that they take time. Unless you
                                                      allowed for that time by sending two characters instead of just one the
                                                      next printable one would have been lost.

                                                      Axel
                                                    Your message has been successfully submitted and would be delivered to recipients shortly.