Re: Most succinct way to parse an HTTP header string
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Most succinct way to parse an HTTP header string
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2013年8月29日 12:07:32 -0300
> 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.
Maybe it is a "split" function what you need?
http://en.wikipedia.org/wiki/String_manipulation_algorithm#split
-- Roberto