lua-users home
lua-l archive

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


Hello all,  

FIrst of all Lua is awesome!  I'm a fairly newbie @ Lua and a total newbie @ LPeg. 

I'm trying to figure out how to do the following. FOr example, I have the following strings, and I only want to match strings a and e.

a = 'disease_show/881/////'
b = 'disease_show/266/tests///'
c = 'disease_show/191/description////'
d = 'disease_show//description////'
e = 'disease_show/881/'


I don't know how to exclude anything that might have letters after the digits and the slash (i.e... b and c)

disease_match = (P'disease_show/'*R'09'^1*P'/'^0)

> = disease_match:match(a)
22
> return  disease_match:match(b)
18
> return  disease_match:match(c)
18
> return  disease_match:match(d)
nil
> return  disease_match:match(e)
18

Regards,

Dano