Class MatchData
In: lib/core/facets/matchdata/match.rb
lib/core/facets/matchdata/matchset.rb
Parent: Object

Methods

match   matchset   matchtree  

Public Instance methods

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

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

CREDIT: Martin DeMello

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

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

CREDIT: Trans

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

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

CREDIT: Trans

[Validate]