Sha256: 191b256cb8e0d003d333ad0f50a3d0fa556a1be443bbb0463678212215baa0af

Contents?: true

Size: 337 Bytes

Versions: 3

Compression:

Stored size: 337 Bytes

Contents

class Regexp

  # Returns the number of backreferencing subexpressions.
  #
  #   /(a)(b)(c)/.arity  #=> 3
  #   /(a(b(c)))/.arity  #=> 3
  #
  # Note that this is not perfect, especially with regards to \x
  # and embedded comments.
  #
  #   CREDIT: Trans

  def arity
    source.scan( /(?!\\)[(](?!\?[#=:!>-imx])/ ).length
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.1 lib/core/facets/regexp/arity.rb
facets-2.2.0 lib/core/facets/regexp/arity.rb
facets-2.3.0 lib/core/facets/regexp/arity.rb