15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/peruby/runtime/regexp_compiler.rb', line 15
def transform(pattern, modifiers = '')
raise CompileError, 'Regexp code execution is not supported' if pattern.match?(/\(\?\??\{/)
pattern = pattern.gsub(/\(\?\^([isx]*):/) { "(?#{Regexp.last_match(1).tr('s', 'm')}:" }
source = rewrite(pattern, multiline: modifiers.include?('m'))
source = extended_character_classes(source) if modifiers.include?('xx')
source = ascii_classes(source) if modifiers.include?('a')
options = 0
options |= Regexp::IGNORECASE if modifiers.include?('i')
options |= Regexp::EXTENDED if modifiers.include?('x')
options |= Regexp::MULTILINE if modifiers.include?('s')
[source, options]
end
|