How to change string.gmatch returning memory address?

Whenever I try to print string.gmatch() it prints an unreadable memory address.
Is there a way to make it print/return something that I can actually read?
Example:
Code:
print(string.gmatch("Hello", "%a+"))
Output:
function: 0x4bdedf296e67671d

It’s returning an iterator function, I think you should look at the string.gmatch documentation. Try string.match instead?

1 Like

Thank you, but how do you read the data in the iterator function? Autocomplete is not showing any methods or attributes.

It’s a function, so it can’t be indexed, and therefore autocomplete shows nothing for it. I think you put it in pairs() in a for loop to get all the matches in the string.

string.gmatch() returns a function. In order to read the data you need to do something like this:

for k in string:gmatch(".") do
     print(k)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.