Reputation: 13
I'm using
raw:gsub("(%a-):\n".."([%wö /,.':&%-%%()\n\t]*)",function(a,b) t[a]=b end)
to split a string called raw
by a section header "Something:\n", which is followed by data including the string "Event: " (note the lack of a newline) and store the data in t["Something"]
.
How can I do this, or should I try to find a workaround?
Upvotes: 1
Views: 166
Reputation: 23767
for a, b in raw:gsub("%f[^\n%z]([^\n]+):\n", "\0%1\0"):gmatch"%z(%Z+)%z(%Z*)" do
t[a]=b
end
The code finds all "headers" (followed by a colon and a newline) and surrounds them with zero-bytes and than traverses all occurrences with gmatch
Upvotes: 1