lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Thu, Apr 2, 2009 at 11:51 AM, Michael Gerbracht <smartmails@arcor.de> wrote:
In article <db3aeaf60903310826u4c31da9bsde1dfad78c803964@mail.gmail.com>,
  Duncan Cross <duncan.cross@gmail.com> wrote:
> Sorry, I just realised a problem with this - it will match something
> with two decimal points, I should move the second fractional bit inside
> the previous if block:
>[program]

Thank you very much, this exactly works in the way I was looking for but I
expected the solution to be simpler and thought that I did not understant
enough of lua's matching syntax. So I guess you are right when you say
that looking into lpeg might be a good idea for similar situations in the
future.

Michael


It seems that Lua's string matching has been made pretty underpowered in order to not bloat the string library out of proportion to the rest of the code. It's still useful in a hell of a lot of situations and definitely better than nothing in my opinion, but yeah, do be aware of this. Two subtle features that make this kind of verbose function-based matching possible are the () position captures and the fact that ^ will match the start of the string at the given index if an index is given (which doesn't seem to be standard for regex systems).

-Duncan