Skip to content

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

instance method

StringScanner#beginning_of_line?

beginning_of_line?

Returns true if and only if the scan pointer is at the beginning of the line.

Example
s = StringScanner.new("test\ntest\n")
s.bol?           # => true
s.scan(/te/)
s.bol?           # => false
s.scan(/st\n/)
s.bol?           # => true
s.terminate
s.bol?           # => true
See also #[] #captures #<< #charpos also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0