class ICU::Regex::Match
- ICU::Regex::Match
- Reference
- Object
Overview
Represents a single match result, including captured groups.
Defined in:
icu/regex.crInstance Method Summary
-
#begin(n : Int32 = 0) : Int32
Returns the byte offset in the input text where the given group begins.
-
#end(n : Int32 = 0) : Int32
Returns the byte offset in the input text just past where the given group ends.
-
#group(n : Int32) : String | Nil
Returns the text of the given capture group (0 = whole match).
-
#group(name : String) : String | Nil
Returns the text of the given named capture group.
-
#group_count : Int32
Returns the number of capture groups in the pattern.
-
#range(n : Int32 = 0) : Range(Int32, Int32)
Returns the match range of the given group as a
Range. -
#to_s : String
Returns the whole match text (group 0).
Instance Method Detail
Returns the byte offset in the input text where the given group begins.
Returns the byte offset in the input text just past where the given group ends.
Returns the text of the given capture group (0 = whole match).
Returns nil if the group did not participate in the match.
m = ICU::Regex.new("(\\w+)").match("hello")
m.group(0) # => "hello"
m.group(1) # => "hello"
Returns the text of the given named capture group.
Returns nil if the group did not participate in the match.
m = ICU::Regex.new("(?<word>\\w+)").match("hello")
m.group("word") # => "hello"
Returns the match range of the given group as a Range.
m = ICU::Regex.new("\\w+").match("hello world")
m.range # => 0...5