Class Regexp
In: lib/core/facets/regexp/arity.rb
lib/core/facets/regexp/multiline.rb
lib/core/facets/regexp/op_add.rb
lib/core/facets/regexp/op_or.rb
lib/core/facets/regexp/to_re.rb
Parent: Object

Methods

+   arity   multiline?   to_re   to_regexp   |  

Public Instance methods

Add regular expressions.

  /a/ + /b/ == /(?-mix:a)(?-mix:b)/

Functionally equivalent to:

  /ab/

CREDIT: Tyler Rick

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

Is a regular expression multiline?

  /x/.multiline?   #=> false
  /x/m.multiline?  #=> true

Simply returns itself. Helpful when converting strings to regular expressions, where regexp might occur as well —in the same vien as using to_s on symbols. The parameter is actaully a dummy parameter to coincide with String#to_re.

  /abc/.to_re  #=> /abc/

CREDIT: Trans

Like to_re, 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

Operator form of `Regexp.union`.

  /a/ | /b/  #=> /(?-mix:a)|(?-mix:b)/

If other is not a Regexp it is passed to Regexp.escape.

[Validate]