Ruby 2.4.1 was released this week and included an upgrade to its underlying regular expression engine, Onigmo. The headline feature in this update was support for 'the absent operator' but what is this and what is it for?
An issue on the Onigmo repository about the absent operator pointed to a Japanese academic paper [PDF] that, to my delight, uses Ruby for its examples. Not being a reader of Japanese, I struggled to grasp the concept but it seemed to promise to provide developers with a new mechanism to more easily notate complex matches.
The next step towards an absent operator in Ruby's regular expressions system dates back 5 years to a suggestion for adding a 'negation flag'. It was suggested that a v flag could negate a regular expression. For example, /(?v:ruby)/ would match anything that /ruby/ didn't.
Source: https://medium.com/rubyinside/the-new-absent-operator-in-ruby-s-regular-expressions-7c3ef6cd0b99
(Score: 4, Informative) by FatPhil on Monday March 27 2017, @01:06PM
If it's similar to the issue that perl went through ages back (yay - lets reinvent the wheel!), then the context may well be this: You're seaerching for "ruby up rails", "ruby in rails", "ruby by rails", "ruby plop rails", and everything that's "ruby [something] rails" but isn't "ruby on rails", then you need the "on" to be absent. Simple negations of matches in traditional regexps, such as /ruby [^o][^n] rails/, will never work. Things that would work tend to have unpleasant explosion of complexity: /ruby (.|o[^n]|[^o]n|...+) rails/, which isn't even correct despite superficially being so - more explosion is required, and don't generalise easily to anything apart from single fixed strings.
Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves