lib/regexp-examples/constants.rb in regexp-examples-1.0.2 vs lib/regexp-examples/constants.rb in regexp-examples-1.1.0
- old
+ new
@@ -15,11 +15,11 @@
# \w = ["a", "b", "c", "d", "e"]
MaxGroupResultsDefault = 5
class << self
attr_reader :max_repeater_variance, :max_group_results
- def configure!(max_repeater_variance, max_group_results)
+ def configure!(max_repeater_variance, max_group_results = nil)
@max_repeater_variance = (max_repeater_variance || MaxRepeaterVarianceDefault)
@max_group_results = (max_group_results || MaxGroupResultsDefault)
end
end
end
@@ -42,10 +42,11 @@
Hex = Array('a'..'f') | Array('A'..'F') | Digit
Word = Lower | Upper | Digit | ['_']
Whitespace = [' ', "\t", "\n", "\r", "\v", "\f"]
Control = (0..31).map(&:chr) | ["\x7f"]
# Ensure that the "common" characters appear first in the array
- Any = Lower | Upper | Digit | Punct | (0..127).map(&:chr)
+ # Also, ensure "\n" comes first, to make it obvious when included
+ Any = ["\n"] | Lower | Upper | Digit | Punct | (0..127).map(&:chr)
AnyNoNewLine = Any - ["\n"]
end.freeze
# Map of special regex characters, to their associated character sets
BackslashCharMap = {