Scanner

# StringScanner Reference Manual

## Class Methods

new( str, dup = true )
  create new StringScanner object. 'str' is string to scan. If DUP is true then duplicate 'str' and use it. 'str' is going to be freezed.

### Methods

scan( regex ): String
  tries matching with 'regex' only on the scan pointer. If matched, advances "scan pointer" and returns matched string. else returns nil.
skip( regex : Regexp ) : Integer
  tries matching with 'regex' only on the scan pointer. If matched, advances "scan pointer" and returns matched length. else return nil.
match?( regex: Regexp ): Integer
  tries matching with 'regex' only on the scan pointer. If matched, keep "scan pointer" un-touched and returns matched length. else return nil.
check( regex ): String
  tries matching with 'regex' only on the scan pointer. If matched, keep "scan pointer" un-touched and returns matched string.
scan_until( regex )
  same to "scan" except this method tries matching not only on the scan pointer.
skip_until( regex )
  same to "skip" except this method tries matching not only on the scan pointer.
exist?( regex )
  same to "match?" except this method tries matching not only on the scan pointer.
check_until( regex )
  same to "check" except this method tries matching not only on the scan pointer.
getch : String
  returns a string on the scan pointer, which represents a one character. also advances scan pointer.
get_byte : String
  returns a 1byte length of string from the scan pointer. also advances scan pointer.
rest : String
  returns string after the byte which is pointed by "scan pointer".
rest? : Boolean
  true if the scan pointer is not at end.
empty
  true if the scan pointer is at end.
rest_size : Integer
  length of 'rest' string
unscan
  reset "scan pointer" to previous index. This method is valid only once for one scanning method call.
matched
  returns matched string. If previous scannnig had failed, raises ScanError exception.
matched_size
  returns length of matched string. If previous scannnig had failed, raises ScanError exception.
self[n]
  returns N-th content of regexp register (indecated by paren in regex). If previous scannnig had failed, raises ScanError exception.
pointer, pointer=(idx)
  index of the scan pointer.
string, string=(str)
  scanning string itself. This string is freezed.

Copyright (c) 1999-2001 Minero Aoki <aamine@loveruby.net>