4

The GNU implementation of the find command uses "Emacs Regular Expressions" by default for its -regex predicate. This can be changed to options such as posix-egrep.

What are the differences in each engine in addition to syntaxes?

For example, do each differ in performance, simplicity?

Should a particular engine be used for specific scenarios (above and beyond personal preferences)?

The version of find is find (GNU findutils) 4.7.0-git

10
  • 2
  • @Kusalananda - The answer suggests that the only difference is syntax. The question I have posted is asking if there are other contrasts.
    – Ryan
    Jan 5 '20 at 17:42
  • @Ryan The answer also states differences in capabilities (lookahead/lookbehind, for instance, which is not just a matter of syntax). As to performance, it's more a matter for specific implementation.
    – xenoid
    Jan 5 '20 at 17:47
  • Which is why I did not mark it as a duplicate. If you are interested in specific implementations, you may want to mention exactly what find you are using. I'm assuming it's GNU find, but the libraries it's using may differ between versions and Unixes.
    – Kusalananda
    Jan 5 '20 at 17:47
  • 1
    @Ryan They are considered non-standard since they are not part of the POSIX specification of the find utility.
    – Kusalananda
    Jan 6 '20 at 7:14
-1

You've asked a question in a daunting subject.

The best resource I can point you to is a PDF/video entitled, "Everything You Know About Regexes Is Wrong" by Damian Conway, former computer science professor (Monash University, Australia) and well-known Perl developer and author:

https://slides.yowconference.com/yowwest2015/Conway-EverythingYouKnowAboutRegexesIsWrong.pdf

https://youtu.be/ubvSjW6Nyqk

In his presentation/PDF, Conway states there are "six major dialects of regular expression syntax" including BRE, ERE, EMACS, VIM, PCRE, and PSIX (the last standing for "PERL6", recently renamed Raku).

As an example, on PDF page 13 Conway shows that a regex written in the VIM/EMACS editor dialects thusly:

/abc\|abx/

is actually written the following way in ERE, PCRE, and PERL6 (i.e. RAKU):

/abc|abx/

A number of other differences are noted, see the presentation/PDF for details.

Caveat emptor: the link https://www.gnu.org/software/gnulib/manual/html_node/Regular-expression-syntaxes.html has been cited here on StackExchange as an authoritative regex reference. However, in point-of-fact that html page makes no mention of either the PERL6 (aka RAKU) regex dialect or even the widely-distributed PCRE regex dialect.

4
  • "now-standard" implies that it's in POSIX. Perhaps you meant widely-used. Sep 15 at 19:31
  • Sure: it has an emulation/whatever for POSIX, but its native API is not POSIX. Sep 15 at 19:44
  • if GNU find uses the the gnulib regex engines, and that manual for it is indeed automatically generated, presumably from something that also generates the matching engines, then I would say that's pretty much as authoritative a source one can get, for those dialects. And the question was about GNU find, not Perl, PCRE, Python or Raku.
    – ilkkachu
    Sep 15 at 22:21
  • I suggest an edit to the title, then. GNU_Find is not mentioned in the title and my reading of the question was about general Regex dialects. FYI this question went unanswered for ~18 months and I was trying to take a 'civic-minded' approach here on U&L. Sep 19 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.