Advertisement
dreais

Untitled

Sep 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. url = "http://ip-measure.com/ftb-api/get_state.php"
  2. str = tostring(http.get(url).readAll())
  3.  
  4. local function split(str, pat)
  5. local t = {} -- NOTE: use {n = 0} in Lua-5.0
  6. local fpat = "(.-)" .. pat
  7. local last_end = 1
  8. local s, e, cap = str:find(fpat, 1)
  9. while s do
  10. if s ~= 1 or cap ~= "" then
  11. table.insert(t,cap)
  12. end
  13. last_end = e+1
  14. s, e, cap = str:find(fpat, last_end)
  15. end
  16. if last_end <= #str then
  17. cap = str:sub(last_end)
  18. table.insert(t, cap)
  19. end
  20. return t
  21. end
  22.  
  23. print(split(str, "<br>"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement