[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Missing string.find functionality in Lua 5.1
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 12 Sep 2005 09:25:44 -0300
> Before this change, it was possible to traverse texts using
> string.find only and obtain everything: whole matches,
> captures and the pieces lying between the matches.
> To get this functionality with Lua 5.1, one should use
> 2 functions instead: string.find and string.match.
> Am I wrong?
You can use empty captures with string.match to know where you are.
string.match(s, "()pat()") is almost equivalent to string.find(s, "pat").
(Usually you can capture more useful and efficient positions.)