Results for: "match"

Compile a MatchWriteNode node

Dispatch enter and leave events for CaseMatchNode nodes and continue walking the tree.

Dispatch enter and leave events for MatchRequiredNode nodes and continue walking the tree.

Dispatch enter and leave events for MatchWriteNode nodes and continue walking the tree.

Inspect a CaseMatchNode node.

Inspect a MatchRequiredNode node.

Inspect a MatchWriteNode node.

Copy a CaseMatchNode node

Copy a MatchRequiredNode node

Copy a MatchWriteNode node

No documentation available

returns match status of CSI/SS3 sequence and matched length

Compile a MatchLastLineNode node

Dispatch enter and leave events for MatchLastLineNode nodes and continue walking the tree.

Inspect a MatchLastLineNode node.

Copy a MatchLastLineNode node

foo in bar ^^^^^^^^^^

case foo; in bar; end ^^^^^^^^^^^^^^^^^^^^^

foo => bar ^^^^^^^^^^

/(?<foo>foo)/ =~ bar ^^^^^^^^^^^^^^^^^^^^

Compile a InterpolatedMatchLastLineNode node

Dispatch enter and leave events for InterpolatedMatchLastLineNode nodes and continue walking the tree.

Inspect a InterpolatedMatchLastLineNode node.

Copy a InterpolatedMatchLastLineNode node

MatchData encapsulates the result of matching a Regexp against string. It is returned by Regexp#match and String#match, and also stored in a global variable returned by Regexp.last_match.

Usage:

url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html'
m = url.match(/(\d\.?)+/)   # => #<MatchData "2.5.0" 1:"0">
m.string                    # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html"
m.regexp                    # => /(\d\.?)+/
# entire matched substring:
m[0]                        # => "2.5.0"

# Working with unnamed captures
m = url.match(%r{([^/]+)/([^/]+)\.html$})
m.captures                  # => ["2.5.0", "MatchData"]
m[1]                        # => "2.5.0"
m.values_at(1, 2)           # => ["2.5.0", "MatchData"]

# Working with named captures
m = url.match(%r{(?<version>[^/]+)/(?<module>[^/]+)\.html$})
m.captures                  # => ["2.5.0", "MatchData"]
m.named_captures            # => {"version"=>"2.5.0", "module"=>"MatchData"}
m[:version]                 # => "2.5.0"
m.values_at(:version, :module)
                            # => ["2.5.0", "MatchData"]
# Numerical indexes are working, too
m[1]                        # => "2.5.0"
m.values_at(1, 2)           # => ["2.5.0", "MatchData"]

Global variables equivalence

Parts of last MatchData (returned by Regexp.last_match) are also aliased as global variables:

See also “Special global variables” section in Regexp documentation.

Search took: 3ms  ·  Total Results: 2599