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

24350RE: [Clip] Advice to add 'Tabs' to data.

Expand Messages
  • flo.gehrke
    Feb 14, 2014
      --In ntb-clips@yahoogroups.com, <jshotsky@...> wrote:

      > One of the things I have been doing is enclosing multiple paren
      > phrases inside an (?= phrase), so that it won't capture, but I
      > wonder if it is captured anyway.

      No, also parens (or a 'group') inside a Lookaround are captured. Test...

      ^!Set %Cheeses%=Cheddar
      ^!Find "\b^%Cheeses%\b(?=(\x20cheese))" RS
      ^!Info ^$GetReSubstrings$

      against 'Cheddar cheese'. The output will be 'cheese' that is captured with the group inside the Lookahead Assertion.

      BTW: I think sometimes it's rather difficult to find out whether the speed of clip execution depends on the search pattern, the clip code or the way it consumes memory. Certain patterns, for example, could cause serious stack problems and lead to wrong results -- cf my message #22824 of June 20, 2012.

      Also there can be clips which are rather slow because the RegEx pattern causes a lot of backtracking. For example, take this line...


      and multiply it to 10,000 lines. Now run the following clip against those lines:

      ^!Find "[01]+.*(aa|bb)" WR

      For me, the clip needs almost a minute to find out that there is no match. That is, that there is no line that ends with 'aa' or 'bb'. However, the problem is not in NT or the clip code but in the RegEx. The trick is to suppress the backtracking because, actually, it isn't needed here. With an Atomic Group...

      ^!Find "(?>[01]+).*(aa|bb)" WR

      the job is done in two seconds.


    • Show all 18 messages in this topic