I've been looking at the parser book created by William Motley and I've been trying to use a variation of the sample parser, but I keep getting the following error.
[Parse] Meta processing failed for session with: Unmatched [ or [^ in character class declaration. The error occured while parsing the regular expression: '9]{10}/[0>>>HERE>>>'.
Looking at the book it says you can't do pattern matching with payload:find, but that is exactly what is being done with the example in the book.
Here is the parser example I'm trying to get to work. Keep in mind this is just to test, I want it to return meta for what stored into the endOfLine variable. Obviously I'll be changing this prior to production.
local getHeader = nw.createParser("noHeader", "Test Meta")
getHeader:setKeys( {nwlanguagekey.create('risk.info')})
function getHeader:httpGet(token, first, last)
local payload = nw.getPayload()
local endOfLine = payload:find("\013\010\\013\010", last + 1, last + 100)
if endOfLine then
local header = payload:tostring(last + 1, endOfLine - 1)
if header then
nw.createMeta(self.keys{"risk.info"], header)
end
end
end
noHeader:setCallbacks({
["^GET "] = getHeader.httpGet,
})
Actually that payload:find wouldn't be looking for a pattern - it would be looking for "carriage-return line-feed carriage-return line-feed":
hexadecimal 0x0D 0x0A 0x0D 0x0A
decimal 13 10 13 10
lua string "\013\010\013\010"
payload:find("\013\010\013\010", ...)
You have an extra "\" in your example, which could be causing the error?