Class: Regexp

Inherits:
Object
  • Object
show all
Defined in:
lib/htree/regexp-util.rb

Instance Method Summary collapse

Instance Method Details

#disable_captureObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/htree/regexp-util.rb', line 2

def disable_capture
  re = ''
  self.source.scan(/\\.|[^\\\(]+|\(\?|\(/m) {|s|
    if s == '('
      re << '(?:'
    else
      re << s
    end
  }
  if re.respond_to? :force_encoding
    re.force_encoding(self.encoding)
    Regexp.new(re, self.options)
  else
    Regexp.new(re, self.options, self.kcode)
  end
end