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

### Methods

match matchset matchtree

### Public Instance methods

match()

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

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

matchset()

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

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

matchtree(index=0)

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       #=> ["XXaabbccddeeffXX", "bb", "ccdd", "dd", "ee"]
      md.matchtree  #=> [["bb"], ["cc", ["dd"]], "ee"]

[Validate]