Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions
by falsedan on Thursday March 23, 2017 @10:30AM
(#13940021)
The article explains that (?~foo) is not the same as (?!foo), since the latter fails the match if it matches, but the former succeeds if it can match anything that's not 'foo' (including 'oo'). The first examples anchor the patterns, so that this behaviour:
"foo" ~= /(?~foo)/ # => 1
isn't revealed.
> I'm pretty sure you can emulate the absent operator with look-ahead expressions. Untested: (?=((?!exp).)*$)
From TFA: "Note that this is not the same as a negative look-behind or look-ahead — we’ll see how shortly."