Module pl.stringio

Reading and writing strings using file-like objects.


  f = stringio.open(text)
  l1 = f:read()  -- read first line
  n,m = f:read ('*n','*n') -- read two numbers
  for line in f:lines() do print(line) end -- iterate over all lines
  f = stringio.create()
  f:write('hello')
  f:write('dolly')
  assert(f:value(),'hellodolly')
 
See the Guide.

Functions

create () create a file-like object which can be used to construct a string.
open (s) create a file-like object for reading from a given string.


Functions

create ()
create a file-like object which can be used to construct a string. The resulting object has an extra value() method for retrieving the string value.

Usage:

    f = create(); f:write('hello, dolly\n'); print(f:value())
open (s)
create a file-like object for reading from a given string.

Parameters:

  • s: The input string.