lua-users home
lua-l archive

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


On Aug 17, 2018, at 8:33 PM, Sean Conner <sean@conman.org> wrote:

> The following code presents the bug:
> 
> url  = require "org.conman.parsers.url.url"
> lpeg = require "lpeg"
> 
> x = url * lpeg.Cp()
> 
> a,b = x:match "/status"   print(b) -- prints 8, okay
> a,b = x:match "/status/"  print(b) -- prints 9, okay
> a,b = x:match "/status "  print(b) -- prints 8, okay
> a,b = x:match "/status/ " print(b) -- prints 8, WAT?

Hi, Sean

Is the expected result  9 ? 10 ?

i do not know how url work, but can segment add space as alternative ?
Or space lookahead (so capture position stay at 9) ?

> The 'segment' rule *should* be 
> 
> segment         <- ! . / {~ pchar* ~}

does above removed end-of-line test ? It seems match everything.

if that is what you want, it seems working:

lua> =re.match("/status/    ", [[ '/' [a-z]+ ('/' [a-z]*)* {} ]])
9