Method: Regexp::Template#analyze

Defined in:
lib/core_ext/regexp.rb

#analyzeObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/core_ext/regexp.rb', line 208

def analyze
  if(!!@rx && !!@rx.source)
    src = @rx.source
  end

  current_segment = ""
  current_atom = {}
  atom_complete = false
  while(!atom_complete)
    src.split('').each do |char|
      current_segment = "#{current_segment}#{char}"
      if(char == "\\")
        current_atom[:escaped] = true
      end
      if(char == ".")
        current_atom[:match] = :any
      end
      if(char == "*")
        current_atom[:count] = :any
      end
    end
  end
end