What do you want to achieve? :match to return the match because there is a match
What is the issue? :match is returning nil, even though when you compare both strings, it returns true as they are the same string but :match is returning nil for some reason
local str1 = "local digit = string.sub(str, i, i)" local str2 = "local digit = string.sub(str, i, i)" print(str1:match(str2))
Your best bet would be to use another type of identifier like a punctuation “!” and “@” to denote paranthesses and then use string.gsub to replace the dot.