[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.lines (a suggestion)
- From: Jamie Webb <j@...>
- Date: Tue, 27 Jul 2004 23:41:58 +0100
On Wed, Jul 28, 2004 at 12:42:59AM +0300, Asko Kauppi wrote:
>
> Lua 5.0 has:
>
> ? io.lines ([filename])
> Opens the given file name in read mode and returns an iterator function
> that, each time it is called, returns a new line from the file.
> Therefore, the construction for line in io.lines(filename) do ... end
> will iterate over all lines of the file.
>
>
> Would it make sense to have an analogous 'string.lines ([str])'
> constructor, allowing a string of multiline text to be easily iterated
> linewise?
Won't string.gfind("[^\n]+") do?
-- Jamie Webb