-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
Due to how this library's algorithm works, look-arounds cannot be supported. As explained in the README, a RegexpExamples::IllegalSyntax
will be raised if they are used in a pattern you attempt to generate examples for.
However, similar to how the library currently "ignores" \G
. ^
and \A
anchors at the beginning of a pattern; or $
, \z
and \Z
at the end; it would also be safe to ignore empty look arounds!
For example, the following could be considered safe:
/foo|bar(?=)/.random_example #=> "foo"
One motivation for this stems from the fact that Regexp.union
returns an empty look-ahead if no patterns are given:
Regexp.union([]) #=> /(?!)/
Therefore one would expect the following to work as follows, rather than raising an exception:
Regexp.union([]).random_example #=> ""