[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: (sub)string comp
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 1 Dec 2012 19:32:18 +0200
> 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