Stories
Slash Boxes
Comments

SoylentNews is people

posted by on Sunday March 26 2017, @11:59PM   Printer-friendly
from the hooray-for-regex dept.

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


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 0) by Anonymous Coward on Monday March 27 2017, @09:48AM (2 children)

    by Anonymous Coward on Monday March 27 2017, @09:48AM (#484564)

    Not familiar with ruby, but wasn't that what {0} suffixes did in most languages? That is, match the absence of a character? Or is there a tacit assumption in the semantics of {0} that it's meaningless, since it matches zero characters, rather than being declarative of an absence?

  • (Score: 0) by Anonymous Coward on Monday March 27 2017, @12:28PM

    by Anonymous Coward on Monday March 27 2017, @12:28PM (#484581)

    Well, this new operator basically does to a general regex what [^abc] does to [abc] at the single-character level.

  • (Score: 2) by FatPhil on Monday March 27 2017, @01:09PM

    by FatPhil (863) <{pc-soylent} {at} {asdf.fi}> on Monday March 27 2017, @01:09PM (#484590) Homepage
    There's a difference between "not something" and "thing that is not something". nothing is "not something", nothing is not a "thing that is not something".
    --
    Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves