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

Re: [Clip] Re: modifying format of stats tool output & concatenating stats from many files

Expand Messages
  • Don - HtmlFixIt.com
    ... Guest appearance ;-) Prodigal son? ... Look ahead and look back assertions are currently over my head -- I need to solve that. It s funny in one way
    Message 1 of 26 , Mar 1, 2010
      > Hi Don, I've missed you!
      Guest appearance ;-) Prodigal son?

      > "(?=" signifies a lookahead assertion. There is an equal sign inside the look ahead assertion, (?=\=). It may not need that backslash, but it makes it easier to see (at least for me). So, an equal sign must follow (looking ahead) the %xxx% to be a match. The equal sign is not actually part of the matched text.

      Look ahead and look back assertions are currently over my head -- I need
      to solve that. It's funny in one way because regex won't search
      backwards, but it will look back ...

      So that bit that kind of looks like a rear end ... (?=\=) ... really is
      just to say "followed by an equals sign." It has three characters (?=
      to say look ahead ... find an equals sign (escaped for good measure) and
      closing parenthesis.

      If we wanted the search pattern followed by a letter R it would be (?=R)
      if I follow correctly ... can it also accept or patterns (?=r|R) and so
      forth?
    • Alec Burgess
      Sheri (silvermoonwoman@comcast.net) wrote (in part) (on 2010-03-01 at ... I was on holiday (got back yesterday) and am just noodling thru the large number of
      Message 2 of 26 , Mar 5, 2010
        Sheri (silvermoonwoman@...) wrote (in part) (on 2010-03-01 at
        15:41):
        > Maybe it would help to know that that clip is meant to be run from the
        > clipbar while clipedit is the active document. It shows the names of
        > variables found in clip currently being edited. GetDocListAll gives
        > the opportunity to format the matches, so they are formatted with the
        > ClearVariable command in front of each one. The purpose is just to
        > help make the list of ClearVariable commands needed to clear only the
        > variables actually Set by the clip being written.
        >
        > It only finds %xxx% if:
        > - it follows a line start followed by ^!Set or ^!SetCode or ^!SetArray
        > and one space, OR if it follows a semicolon (anywhere on a line) plus
        > an optional space
        > - it is followed by an equal sign
        I was on holiday (got back yesterday) and am just noodling thru the
        large number of posts during the past week.

        I read this thread but didn't test any of the example code.

        > > > ^!Set %varnames%="
        >
        > ^$GetDocListAll("(?i)(^\^\!Set(Array|Code)?\x20|;\x20?)\K%[\d\pL_]+?%(?=\=)";"^!ClearVariable
        > $0\r\n")$"
        >


        Sheri: wrt to your "find variables for clearing" clip. You appear from
        the comments but haven't checked the regex itself, to be expecting a
        variable xxx to be defined as:
        ^!set %xxx%=asdf
        Following works though I use the construct without %...% only
        accidentally :-[ :
        ^!set xxx=asdf
        ^!info ^%xxx%

        Will your clip capture this usage?

        >
        > "(?=" signifies a lookahead assertion. There is an equal sign inside
        > the look ahead assertion, (?=\=). It may not need that backslash, but
        > it makes it easier to see (at least for me). So, an equal sign must
        > follow (looking ahead) the %xxx% to be a match. The equal sign is not
        > actually part of the matched text.
        >
        > The search is case insensitive so that ^!set works as well as ^!Set or
        > any other mixed case that might be found.


        --
        Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




        [Non-text portions of this message have been removed]
      • Sheri
        ... No, of course not. :) But (sigh) I suppose by failing to capture them, it is remotely possible that some accidental variables would fail to get released.
        Message 3 of 26 , Mar 6, 2010
          --- In ntb-clips@yahoogroups.com, Alec Burgess <buralex@...> wrote:
          >
          > Sheri (silvermoonwoman@...) wrote (in part) (on 2010-03-01 at
          > 15:41):
          > >
          > > ^$GetDocListAll("(?i)(^\^\!Set(Array|Code)?\x20|;\x20?)\K%[\d\pL_]+?%(?=\=)";"^!ClearVariable
          > > $0\r\n")$"
          > >
          >
          > Sheri: wrt to your "find variables for clearing" clip. You appear
          > from the comments but haven't checked the regex itself, to be
          > expecting a
          >
          > variable xxx to be defined as:
          > ^!set %xxx%=asdf
          > Following works though I use the construct without %...% only
          > accidentally :-[ :
          > ^!set xxx=asdf
          > ^!info ^%xxx%
          >
          > Will your clip capture this usage?
          >

          No, of course not. :)

          But (sigh) I suppose by failing to capture them, it is remotely possible that some "accidental" variables would fail to get released.

          So perhaps it would be better to modify the capture part as follows:

          ^!Set %varnames%="^$GetDocListAll("(?i)(^\^\!Set(Array|Code)?\x20|;\x20?)\K(%?)([\d\pL_]+?)\3(?=\=)";"^!ClearVariable %$4%\r\n")$"

          Regards,
          Sheri
        Your message has been successfully submitted and would be delivered to recipients shortly.