Skip to content

Enhancements to absent operator examples #22

Open
@tom-lord

Description

@tom-lord

The "best" way to replicate generating examples for absent operator groups is with a negative lookbehind, e.g:

(?~abc) --> (?:.(?<!abc))*

But since look-behinds are irregular, this library cannot support that! A possible workaround would be to replace the group with a repetition of the first letter negated, e.g:

(?~abc) --> (?:[^a]*)

However (!!) this generalisation is not always possible:

(?~\wa|\Wb) --> ???

Therefore, the only 100% reliable option - which is what this gem currently does - is just to match "nothing"!

/(?~abc)/.examples #=> [""]

However, as shown above, this library could, at least, be enhanced to deal with specific scenarios in better ways. But such a strategy needs to be optimised for generalisation and reliability.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions