Class MatchData
In: lib/facet/matchdata/matchtree.rb
lib/facet/matchdata/matchset.rb
lib/facet/matchdata/match.rb
Parent: Object

Methods

match   matchset   matchtree  

Public Instance methods

Return the primary match string. This is equivalent to +md[0]+.

  require 'facet/matchdata/match'

  md = /123/.match "123456"
  md.match  #=> "123"

Returns [ pre_match, matchtree, post_match ]. (see matchtree)

An alternate to to_a which returns the matches in order corresponding with the regular expression.

  require 'facet/matchdata/matchtree'

  md = /(bb)(cc(dd))(ee)/.match "XXaabbccddeeffXX"
  md.to_a      #=> ["XXaabbccddeeffXX", "bb", "ccdd", "dd", "ee"]
  md.matches  #=> ["XXaa", [["bb"], ["cc", ["dd"]], "ee"], "ffXX"]

[Validate]