Ok I got it... I dont understand how but it was caused by a combo of the infinite loop and the regex match pattern. I am new to it and didnt realise normal regex's from other luas wouldnt neccesarily work.
Below is my modified working code.
Code:
function URLFind(str)
local _results = {}
local _x = 0
local isFound = false
while _x <= #str do
url = ""
pos = 0
url = string.match(str, "[https?://]*[www%.]*%w+%.%w+[%w+/]+", _x)
pos = string.find(str, "[https?://]*[www%.]*%w+%.%w+[%w+/]+", _x)
--print(url)
if url ~= nil then
if url:sub(1,1) == " " then
url = url:sub(2, #str)
pos = pos + 1
end
table.insert(_results, {url, pos})
--print(url.." | "..pos)
_x = pos + #url
--print("Adding. Next X: ".._x)
isFound = true
end
_x = _x + 1
end
return isFound, _results
end