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
# File lib/core/facets/regexp/arity.rb, line 13 13: def arity 14: source.scan( /(?!\\)[(](?!\?[#=:!>-imx])/ ).length 15: end
Simply returns itself. Helpful when converting strings to regular expressions, where regexp might occur as well —in the same vien as using # on symbols. The parameter is actaully a dummy parameter to coincide with String#to_re.
/abc/.to_re #=> /abc/
CREDIT: Trans
# File lib/core/facets/regexp/to_re.rb, line 24 24: def to_re(esc=false) 25: self # Of course, things really should know how to say "I" ;) 26: end
Like #, but following Ruby’s formal definitions, only a Regular expression type object will respond to this.
Note that to be of much real use this should be defined in core Ruby.
CREDIT: Florian Gross
# File lib/core/facets/regexp/to_re.rb, line 10 10: def to_regexp 11: self 12: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.