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

Semicolon in regex causes error in SetListDelimiter statement

Expand Messages
  • joy8388608
    Why does the semicolon in %SearchString% (after :,.) cause an error on the SetListDelimiter statement? To test, run this against a document containing at least
    Message 1 of 4 , Apr 12, 2011
    • 0 Attachment
      Why does the semicolon in %SearchString% (after :,.) cause an error on the SetListDelimiter statement?

      To test, run this against a document containing at least one URL such as 'www.here.com'.

      I got this regex from Regular Expressions Cookbook and replaced the regex I was using to match URLs. It took me a while to find what was causing the error but I don't understand why.

      %Left% and %Right% do have meaning if you saw the entire clip since they sometimes have a value.

      ^!Setdebug on
      ^!Set %SearchString%=((https?|ftp|file)://|(www|ftp)\.)[-A-Za-z0-9+&@#/%?=~_|$!:,.;]*[A-Za-z0-9+&@#/%=~_|$]
      ^!ClearVariable %Left%
      ^!ClearVariable %Right%
      ^!Jump Text_Start
      ^!Replace "^%SearchString%" >> "^%Left%$0^%Right%" RTIWAS
      ^!SetListDelimiter ^p
      ^!Set %List%=^$GetDocMatchAll("^%SearchString%")$
      ^!Info ^%List%

      Thanks once again for helping me understand the odd situations I seem to be so good at finding.

      Joy
    • Sheri
      ... The error I see single stepping is a regex error, not an error on the SetListDelimiter statement. The problem is in NoteTab s parsing of the
      Message 2 of 4 , Apr 12, 2011
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "joy8388608" <mycroftj@...> wrote:
        >
        > Why does the semicolon in %SearchString% (after :,.) cause
        > an error on the SetListDelimiter statement?

        The error I see single stepping is a regex error, not an error on the SetListDelimiter statement.

        The problem is in NoteTab's parsing of the ^$GetDocMatchAll$ function which follows the SetListDelimiter statement. That function has an optional second parameter, and the second parameter follows a semicolon.

        If you include ;0 after the pattern in parameters for ^$GetDocMatchAll, it resolves. Zero is generally the default when the second parameter is omitted. Otherwise NoteTab splits the parameters at the semicolon and terminates the pattern portion early.

        Another issue with ^$GetDocMatchAll$ is sometimes seen when a pattern has ")$" in it -- NoteTab prematurely terminates the function. The solution for that one is to use the ^%dollar% instead of the dollar sign in the pattern.

        I noticed you didn't surround the string assigned to %SearchString% with double quotes. I would suggest to always use them. Use of double quotes sometimes avoids clipcode issues (but not in this case).

        Regards,
        Sheri
      • joy8388608
        ... Thank you, Sheri, for the quick reply with the quote suggestion and for the reason for my problem. I d not have figured that one out. You showed me another
        Message 3 of 4 , Apr 12, 2011
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
          >
          > --- In ntb-clips@yahoogroups.com, "joy8388608" <mycroftj@> wrote:
          > >
          > > Why does the semicolon in %SearchString% (after :,.) cause
          > > an error on the SetListDelimiter statement?
          >
          > The error I see single stepping is a regex error, not an error on the SetListDelimiter statement.
          >
          > The problem is in NoteTab's parsing of the ^$GetDocMatchAll$ function which follows the SetListDelimiter statement. That function has an optional second parameter, and the second parameter follows a semicolon.
          >
          > If you include ;0 after the pattern in parameters for ^$GetDocMatchAll, it resolves. Zero is generally the default when the second parameter is omitted. Otherwise NoteTab splits the parameters at the semicolon and terminates the pattern portion early.
          >
          > Another issue with ^$GetDocMatchAll$ is sometimes seen when a pattern has ")$" in it -- NoteTab prematurely terminates the function. The solution for that one is to use the ^%dollar% instead of the dollar sign in the pattern.
          >
          > I noticed you didn't surround the string assigned to %SearchString% with double quotes. I would suggest to always use them. Use of double quotes sometimes avoids clipcode issues (but not in this case).
          >
          > Regards,
          > Sheri
          >

          Thank you, Sheri, for the quick reply with the quote suggestion and for the reason for my problem. I'd not have figured that one out.

          You showed me another thing I didn't know. I thought EVERYTHING after the equal sign in a SET statement was taken literally - even quotes but I see not. It wasn't until I put three together (Set %X%="""test""") that X was set to test with quotes. I don't remember reading about this. So what should be in quotes for a SET statement? Everything that is not a number???

          It's a shame there isn't some central place for everyone to post notes and additional explanations for the help files. Yes, I'm sure keeping it all in order would be a big job. I know my notebook contains many notes like my new one on GetDocMatchAll and semicolons.

          Thanks again,

          Joy
        • bruce.somers@web.de
          I there something wrong with my mail display? I see no semicolon. I see a colon, a comma and a period. Bruce
          Message 4 of 4 , Apr 13, 2011
          • 0 Attachment
            I there something wrong with my mail display? I see no semicolon. I see a colon, a comma and a period.

            Bruce


            > Why does the semicolon in %SearchString% (after :,.) cause
            > an error on the SetListDelimiter statement?
          Your message has been successfully submitted and would be delivered to recipients shortly.