[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Most succinct way to parse an HTTP header string
- From: David Crayford <dcrayford@...>
- Date: Thu, 29 Aug 2013 22:13:37 +0800
I've ported Lua to IBM mainframes and it's a joy and very fast, in some
cases by over an order of magnitude. However, selling it is going to be
difficult to the masses that grew up on REXX.
I want to parse a HTTP header string "name:value" pair. In REXX this is
quite simple with the parse instruction, "parse var line name ":"
value". In lua it seems much trickier using
the example i have "local _, _, name, value = string.find(line, "^([^:
]+)%s*:%s*(.+)")". I understand that captures are much more powerful but
what I want is to dumb them down so there
is a lower entry level of skill required to do what is simple in REXX.
Maybe it's possible to write a parse(line,"%s : %s:) function or
something similar. It's most likely the case that I just don't
know Lua string handling well enough to grok what is the best solution.