In some regex flavors, [negative] zero-width assertions (look-ahead/look-behind) are not supported.
This makes it extremely difficult (impossible?) to state an exclusion. For example ‘every line that does not have ‘foo’ on it’, like this:
^((?!foo).)*$
Can the same thing be achieved without using look-around at all (complexity and performance concerns set aside for the moment)?
UPDATE: It fails ‘with two ff before oo’ as @Ciantic pointed out in the comments.
NOTE: It is much much easier just to negate a match on the client side instead of using the above regex.
The regex assumes that each line ends with a newline char if it is not then see C++’s and grep’s regexs.
Sample programs in Perl, Python, C++, and
grepall give the same output.perl
python
c++
grep
Sample file:
Output: