lib/regexp-examples/chargroup_parser.rb in regexp-examples-1.4.0 vs lib/regexp-examples/chargroup_parser.rb in regexp-examples-1.4.1
- old
+ new
@@ -65,11 +65,11 @@
parse_posix_group(Regexp.last_match(1), Regexp.last_match(2)) if @is_sub_group
end
end
def parse_posix_group(negation_flag, name)
- @charset.concat negate_if(POSIXCharMap[name], !negation_flag.empty?)
+ @charset.concat negate_if(CharSets::POSIXCharMap[name], !negation_flag.empty?)
@current_position += (negation_flag.length + # 0 or 1, if '^' is present
name.length +
2) # Length of opening and closing colons (always 2)
end
@@ -82,17 +82,14 @@
[next_char]
end
end
def parse_after_backslash
- case next_char
- when 'b'
+ if next_char == 'b'
["\b"]
- when *BackslashCharMap.keys
- BackslashCharMap[next_char]
else
- [next_char]
+ CharSets::BackslashCharMap.fetch(next_char, [next_char])
end
end
def parse_sub_group_concat
@current_position += 1
@@ -120,15 +117,14 @@
end
def parse_after_hyphen
if regexp_string[@current_position + 1] == ']' # e.g. /[abc-]/ -- not a range!
@charset << '-'
- @current_position += 1
else
@current_position += 1
@charset.concat((@charset.last..parse_checking_backlash.first).to_a)
- @current_position += 1
end
+ @current_position += 1
end
def rest_of_string
regexp_string[@current_position..-1]
end