Method: Interscript::Compiler::Ruby#build_regexp

Defined in:
lib/interscript/compiler/ruby.rb

#build_regexp(r, map = @map) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/interscript/compiler/ruby.rb', line 120

def build_regexp(r, map=@map)
  from = compile_item(r.from, map, :re)
  before = compile_item(r.before, map, :re) if r.before
  after = compile_item(r.after, map, :re) if r.after
  not_before = compile_item(r.not_before, map, :re) if r.not_before
  not_after = compile_item(r.not_after, map, :re) if r.not_after

  re = ""
  re += "(?<=#{before})" if before
  re += "(?<!#{not_before})" if not_before
  re += from
  re += "(?!#{not_after})" if not_after
  re += "(?=#{after})" if after
  re
end