lib/regexp-examples/groups.rb in regexp-examples-0.5.2 vs lib/regexp-examples/groups.rb in regexp-examples-0.5.3

- old
+ new

@@ -46,9 +46,19 @@ def result [GroupResult.new(@char)] end end + # Used as a workaround for when a grep is expected to be returned, + # but there are no results for the group. + # i.e. PlaceHolderGroup.new.result == '' == SingleCharGroup.new('').result + # (But using PlaceHolderGroup makes it clearer what the intention is!) + class PlaceHolderGroup + def result + [GroupResult.new('')] + end + end + class CharGroup prepend GroupWithIgnoreCase def initialize(chars, ignorecase) @chars = chars @ignorecase = ignorecase