(The data are aligned with each other. I did not find how to write the formatted data on this website)
IP: 192.168.128.12
MAC: AF:3G:9F:c9:32:2E
Expires: Fri Aug 13 20:04:53 2010< br> Time Left: 11040 seconds
The results should be placed in a table like this:
t = {“IP” : “192.168.128.12”, “MAC”: “AF:3G:9F:c9:32:2E”, “Expires”: “Fri Aug 13 20:04:53 2010”, “Time Left”: “11040 seconds” }
I tried:
for k,v in string.gmatch(data, "([%w]+): ([%w%p%s]+ ") do
t[k] = v
end
That was my best attempt.
< /div>
local s = "IP: 192.168.128.12 MAC: AF:3G:9F:c9:32:2E Expires: Fri Aug 13 20:04:53 2010 Time Left: 11040 seconds"
local result = {}
result["IP"] = s:match("IP: (%d+.%d+.%d+.%d+)")
result["MAC "] = s:match("MAC: (%w+:%w+:%w+:%w+:%w+:%w+)")
result["Expires"] = s:match("Expires: ( %w + %w+ %d+ %d+:%d+:%d+ %d+)")
result["Time Left"] = s:match("Time Left: (%d+ %w+)")
I used Lua to split the following strings into tables:
(The data are aligned with each other. I did not find how to write the formatted data on this website)
IP: 192.168.128.12
MAC: AF:3G:9F:c9:32:2E
Expires: Fri Aug 13 20:04:53 2010< br> Time Left: 11040 seconds
The results should be placed in a table like this:
t = {“IP” : “192.168.128.12”, “MAC”: “AF:3G:9F:c9:32:2E”, “Expires”: “Fri Aug 13 20:04:53 2010”, “Time Left”: “11040 seconds” }
I tried:
for k,v in string.gmatch(data, "([%w]+): ([%w%p%s]+ ") do
t[k] = v
end
That was my best attempt.
< /p>
If I understand your use case, the following should solve the problem. It may need to be adjusted slightly.
local s = "IP: 192.168.128.12 MAC: AF:3G:9F:c9:32:2E Expires: Fri Aug 13 20:04:53 2010 Time Left: 11040 seconds"
local result = {}
result["IP"] = s:match("IP: (%d+.%d+.%d+.%d+)")
result["MAC"] = s:match("MAC: (% w+:%w+:%w+:%w+:%w+:%w+)")
result["Expires"] = s:match(" Expires: (%w+ %w+ %d+ %d+:%d+:%d+ %d+)")
result["Time Left"] = s:match("Time Left: (%d+ %w+)")
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3277 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC