Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

StringScanner#size

size

Returns the amount of subgroups in the most recent match. The full match counts as a subgroup.

Example
s = StringScanner.new("Fri Dec 12 1975 14:39")
s.scan(/(\w+) (\w+) (\d+) /)       # -> "Fri Dec 12 "
s.size                             # -> 4
See also #search_full #skip #scan_until #skip_until also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0