[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lpeg for a filename
- From: Georgios Petsagourakis <petsagouris+lual@...>
- Date: Mon, 25 Nov 2013 19:28:40 +0000 (UTC)
Hello all,
I am trying to get lpeg to catch filenames.
I found that there is a set of not allowed characters for the filenames or
extensions which are the following:
/ \ ? % * : | " < > .
I need an lpeg pattern to get:
file.name.ext --> file.name ext
file.ext --> file ext
At the moment I am trying the following:
local extension = lpeg.P('.') * lpeg.P(1 - lpeg.P('.')) * lpeg.P(-1)
local filename_characters = lpeg.P(lpeg.P(1) -lpeg.S('\\?|"<>'))^1
local filename = lpeg.P(1 - lpeg.P(extension))
but it produces nothing. Can anyone give me a hand?