|
From: John M. <joh...@ed...> - 2019-11-05 16:27:25
|
Hi Bernard >> 2. I often need to find an arbitrary number of nested delimiters. I found information about recursive searches that can do this. I know this can be done with some flavors of GREP, but it does not work with Alpha. It would be really cool if it did with in Alpha. > > Do you have a pointer to this information about recursive searches. I’m not sure I understand what you’re referring to? I found a good entry point to the discussion on Stackoverflow at <https://stackoverflow.com/questions/133601/can-regular-expressions-be-used-to-match-nested-patterns>. The comments give plenty of discussion about why regular expressions can’t theoretically do recursion, but a few comments mention “context-free expressions,” which allow backtracking using an external stack. One comment mentions some tools that implement this possibility: > From the books, regular expressions can't do that, but context-free expressions can. From the tools, modern expression parsers will call regular expressionsomething that is using an external stack, meaning able to backtrack, meaning able to recurse: those are context-free expressions in practice and as such you can do it as a one-liner with simili-PCRE2 (PHP, Java, .NET, Perl, ...) or ICU-compliant (Obj-C/Swift) tools, often with the (?>...) syntax, or alternatives such as the (?R) or (?0) syntaxes. – Cœur Aug 5 '15 at 7:38 Of course, I don’t expect you to reinvent this yourself. I was just wondering if is is a matter of changing a switch in the current grep engine or using an easily accessible different grep engine in the modern Alpha. Best, John |