Skip to content
instance method

StringScanner#string=

(::String) -> ::String
string = other_string → other_string

Replaces the stored string with the given other_string:

Example
scanner = StringScanner.new('foobar')
scanner.scan(/foo/)
put_situation(scanner)
# Situation:
#   pos:       3
#   charpos:   3
#   rest:      "bar"
#   rest_size: 3
match_values_cleared?(scanner) # => false

scanner.string = 'baz'         # => "baz"
put_situation(scanner)
# Situation:
#   pos:       0
#   charpos:   0
#   rest:      "baz"
#   rest_size: 3
match_values_cleared?(scanner) # => true
See also #string #terminate #skip_until #unscan also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0