I want to know where the http url link ends
It ends at the space, so just find everything that's not a space:
str:find('%S+')
FYI, if you're just trying to extract that portion of the string, you should use match
instead:
str:match('%S+')
EDIT: adding clarification per the discussion below.
Note that we are not trying to parse URLs here. We're parsing tokens in a space-delimited string.
We have to assume that the URL contains no unencoded spaces, because otherwise the URL could be any of the following and we have no way of distinguishing between them:
http://www.abc.com?id=123&key=456
http://www.abc.com?id=123&key=456 and
http://www.abc.com?id=123&key=456 and more
http://www.abc.com?id=123&key=456 and more text
http://www.abc.com?id=123&key=456 and more text here
Again, the URL exists in a sentence where words are delimited by spaces, so we have to assume/require that the URL contains no unencoded spaces, which makes finding its end easy.