Class: Regexp
Instance Method Summary collapse
Instance Method Details
#arity ⇒ Object
17 18 19 |
# File 'lib/capcode/core_ext.rb', line 17 def arity #:nodoc: self.source.scan( /(?!\\)[(](?!\?[#=:!>-imx])/ ).length end |
#number_of_captures ⇒ Object
:nodoc:
8 9 10 11 12 13 14 |
# File 'lib/capcode/core_ext.rb', line 8 def number_of_captures #:nodoc: c, x = 0, self.source.dup.gsub( /\\\(/, "" ).gsub( /\\\)/, "" ) while( r = /(\([^\)]*\))/.match( x ) ) c, x = c+1, r.post_match end c end |