lua-users home
lua-l archive

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


> I personly have a usage of such a func for a parsing lib:
> the simplest, and ultimately terminal pattern matching func,
> for literals or possibly multibyte chars, is just that:
> source:contains_at(sub, current_idx).

It's available in lpeg, written by a certain R. Ierusalimschy
of PUC-Rio.

lpeg=require"lpeg"
a="qwertyuiop"
current_idx=4
current_idx=lpeg.match("tyu",a,current_idx) or current_idx
print(current_idx) --> 4
current_idx=5
current_idx=lpeg.match("tyu",a,current_idx) or current_idx
print(current_idx) --> 8