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

24114RE: RE: [Clip] REGEX Search Backward

Expand Messages
  • John Shotsky
    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?

    • Show all 25 messages in this topic