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

RE: [Clip] time stats

Expand Messages
  • John Shotsky
    For K I think of it this way: Anything before a K is going to stay there, regardless of what else you do. Anything you have in parens within the section
    Message 1 of 9 , Jun 20, 2012
    • 0 Attachment
      For \K
      I think of it this way:
      Anything before a \K is going to stay there, regardless of what else you do. Anything you have in parens within the
      section before a \K is available just like any other paren capture for replacement AFTER the \K, but not before, because
      the before is not going to be touched.

      An easy way to insert something in the midst of a line is to end the first part with \K, and start the next section with
      (?=text) Neither of those will be moved, but if you add something with a replace, it will go between those two points. I
      do that all the time.

      If you want to remove some duplicated text, you can use \K also:
      Sample line:
      Text1 then some more text followed by Text1 again
      Command:
      Replace (Text1).*\K\1 with 'nothing' does it.
      Result:
      Text1 then some more text followed by again

      Best way to learn is to play with it. Try things until you have it internalized, then it becomes a tool.
      Regards,
      John
      RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Don
      Sent: Wednesday, June 20, 2012 18:03
      To: ntb-clips@yahoogroups.com
      Subject: Re: [Clip] time stats


      I will always be interested in the clip so keep on rolling there.

      I am unlikely to have > 200 here anytime soon but good to know. I also
      found something the other day called atomic grouping that helped with
      some doggy regex I was working on. That was an .net search ... I'll
      admit I learn more regex daily.

      Next I want to figure out how much time between each finisher and the
      minimum and maximum splits and the frequency of those ... it that makes
      sense.

      You did more in three lines than I did in hours. :-) Next off to find
      what this means: (?x)

      And I still don't get the \K and when I can use it :-) ... non-capturing
      but only for a (set of data in parenthesis?)?

      On 6/20/2012 10:13 AM, flo.gehrke wrote:
      > --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , Ian NTnerd <indiamcq@...> wrote:
      >>
      >> I see Flo has done a RE version. It should be much faster,...
      >
      > I should add that you could encounter a glitch if the RegEx in this clip matches a group of lines of about 200 or more
      lines. NT 7.0 just doesn't match that group -- without any message.
      >
      > When testing this with the DIRegEx Workbench (see message #22606), it returns "PCRE Error Recursionlimit". Probably,
      the backreference is causing a stack problem here (cf "PCRE Discussion of Stack Usage" in http://www.pcre.org/pcre.txt.)
      >
      > According with that documentation, you can easily work around that issue by using a Possessive Quantifier -- in this
      case, with...
      >
      > ^(\d{2}).+\R(?:\1.*(\R|\Z))++
      >
      > In my view, it's IMPORTANT to know that NT 7.0 doesn't return an error message here. So you could miss data without
      even noticing it. (I don't know if it was different in v6.2 -- haven't installed it any more.)
      >
      > If you still are interested in that clip -- here's another solution which should be even faster because it doesn't
      process those groups line by line but in an array:
      >
      > ^!SetScreenUpdate Off
      > ; Next one long line!
      > ^!SetArray %Groups%=^$GetDocListAll("(?x)^(\d{2}).+\R(?:\1.*(\R|\Z))++ | ^(\d{2}).+(\R|\Z)";"$0;")$
      > ^!Set %i%=0
      >
      > :Loop
      > ^!Inc %i%
      > ^!If ^%i%=^%Groups0% Out
      > ^!Set %Current%=^%Groups^%i%%
      > ^!Set %GrNr%=^$StrCopyLeft(^%Current%;2)$
      > ^!Set %Freq%=^$StrCount(^%Colon%;^%Current%;0;0)$
      > ^!Set %Groups^%i%%=^%GrNr%-^%Freq%^P
      > ^!Goto Loop
      >
      > :Out
      > ^!Select All
      > ^!InsertText ^%Groups%
      > ^!Replace ";" >> "" WAS
      > ^!Jump Doc_Start
      >
      > Regards,
      > Flo
      >
      >
      >
      >
      > ------------------------------------
      >
      > Fookes Software: http://www.fookes.com/
      > NoteTab website: http://www.notetab.com/
      > NoteTab Discussion Lists: http://www.notetab.com/groups.php
      >
      > ***
      > Yahoo! Groups Links
      >
      >
      >
      >



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.