24353Re: [Clip] Advice to add 'Tabs' to data.
- Feb 14, 2014--In firstname.lastname@example.org, <don@...> wrote:
> Atomic groups are something still a little past my grasp, though I use
> them when I experience slow downs. I don't always understand why or
> when. \K ... I'm working on it. Lookaheads and so forth I have down
> pretty well now.
Well, Don, in short, an Atomic Group says: "Don't look back if you don't achieve a match!" (similar to Possessive Quantifiers and certain Verbs).
On the other hand: Be careful! Backtracking is absolutely necessary where the RegEx Engine must test alternations or options.
Example: Given a string of 10,000 lines like...
The following clip uses an Atomic Group in order to test if there is any line that ends with '11'...
^!Find "^(?>+)11$" WR
The result will be "No match!" though there are 10,000 lines ending with '11'.
Since the Engine doesn't look back, all characters are consumed already with '+'. Now, at the end of each line, the Engine tests for '11'. Since there is no '11' left, the testing fails, and there is no match.
- << Previous post in topic