What types of regex DO support (e.g.) negative lookbehind?

Bash on GNU:

I am using a collection of find commands, most of which employ -regex to do their matching. Each time I try a different feature in my regex I have to cycle through the values for -regextype until one works. My particular need in this case is for one that supports negative lookbehind. It’s hard to validate the (zero) results of my tests on this feature so I would like to simply refer to a list rather than repeating increasing series of tests.

I have found many references to Javascript and other platforms not supporting negative lookbehind, but I can’t seem to find a central location for those which do.

It would be nice to see a chart somewhere listing many of the popular regex styles and the features they do and do not support, but I couldn’t find that either.

Asked By: WAF


If you want a find whose -regex supports look-around operators à la perl, you can use ast-open’s find:

$ find /etc -regex '.*(?<!g)shadow'

-regextype is specific to the GNU implementation of find and none of the regex types it supports have look-around operators AFAIK.

Answered By: Stéphane Chazelas
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.