Releases: tom-lord/regexp-examples
POSIX group support
Examples can now be generated for POSIX groups (including negated groups), e.g.
/[[:alpha:]]/.examples
Also a significant code refactor, laying the foundations for the needed Chargroup parser refactor
Escaped octal characters supported
The following now works:
/\10/.examples # => ["\x08"]
And if you do have 10+ backreferences in the pattern, then these will correctly take precedence over the octal character interpretation.
Better escaped character support
You can now include \G at the start of the pattern,
or \X in the pattern,
or \K (anywhere, because it's basically just ignored!) in the pattern,
or \R in the pattern.
(Note: Some of this stuff isn't even mentioned on ruby-doc.org!!)
These missing features were picked up due to adding a more rigorous (complete) list of tests.
Also a couple of odd bug fixes.
Option toggling
Option toggling within the pattern is now fully supported. For example:
/ab(?i)c/.examples #=> ["abc", "abC"]
/a(?-i:bc)/i.examples #=> ["abc", "Abc"]
Also added support for comment groups, such as /foo(?#comment)bar/.examples
Full options suppport
Multiline and extended options now supported. Both of the following now work:
/./m.examples(max_group_results: 999)
/
line 1 # comment
line 2
/x.examples
Ignorecase now supported
For example:
/cool/i.examples # => ["cool", "cooL", "coOl", "coOL", ...]
Previously, the ignorecase flag was just.... ignored.
Full modifiers and backreference support
Fixed various important edge cases, like non-greedy operator, and some backreference scenarios.
For example, all of the following not work, which did not in the previous version:
/a++/.examples
/a{1}?/.examples
/([ab]){2} \1/.examples
Non-greedy quantifiers
Non-greedy quantifiers are not regular, and will not always work - i.e. when using them in combination with certain capture groups and back-references.
However, they are now at least implemented with a warning message.
Configuration options added
Added new feature: Config options max_repeater_variance
and max_group_results
. For full details, refer to README.
Various bug fixes... Most significantly: ALL valid examples are now being returned, e.g. /[ab]{2}/.examples
now includes "ab"
and "ba"
, whereas before it did not.
Number of examples improved
The main (noticable) change is that the number of examples generated for repeaters is better defined:
.* is equivalent to .{0,2}
.+ is equivalent to .{1,3}
.{2,} is equivalent to .{2,4}
.{,3} is equivalent to .{0,2}
.{3,8} is equivalent to .{3,5}
There are also various bug fixes, such as:
- Empty character sets, e.g.
/[^\w\W]/.examples
(Previously returned["-"]
; now[]
) - Mixing OrGroups and backreferences, e.g.
/(a|b)\1/.examples
(Previously didn't work properly, at all)