Sha256: 0749530e30078efcef0d62ec3a565c93a6e02a47d46d10f646055a58bec865e1

Contents?: true

Size: 336 Bytes

Versions: 7

Compression:

Stored size: 336 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

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/regexp/arity.rb
facets-2.4.1 lib/facets/regexp/arity.rb
facets-2.4.2 lib/core/facets/regexp/arity.rb
facets-2.4.3 lib/core/facets/regexp/arity.rb
facets-2.4.4 lib/core/facets/regexp/arity.rb
facets-2.4.5 lib/core/facets/regexp/arity.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/regexp/arity.rb