Help with manipulating strings to find a period in it

I want to write a script that will correctly detect whether there is a period in a string. However, the script detects the first character it finds as a period. Are periods treated differently/weirdly? Any assistance is appreciated.

My code

print(string.match("oof", "."))

What I expect to happen
Output should print nil

What actually happens
Script treats first character it finds as a period

do string.find instead and see if it works

I tried it already. It does not work and returns 1 1 (the start and end indexes of the first character in the string).

print(string.find("oof", "%.")) --> nil
print(string.find("oo.f", "%."))  --> 3, 3

Since according to the documentation, the . parameter means any character.

1 Like

i think its because it doesnt find it and returns 1 instead
so do this

local result = string.find(msg,".")
if result == "1 1" then
result = nil
end

Periods are a special character (look up special characters to know what those are). To get it to function like a normal period, put a % before it (%.)

1 Like

Ah, I see. Thanks for the help!

wow i have been outsmarted time to leave

1 Like

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