This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
98Games_YT's profile picture

How to find any version of a string

Started by 98Games_YT, 12 July 2015 - 05:48 PM
98Games_YT #1
Posted 12 July 2015 - 07:48 PM
How do I find any version of a string? For example, I type in Testing and it works. I type in Testing like testing and it still works.
Lignum #2
Posted 12 July 2015 - 08:41 PM
To do this, you simply have to convert both strings to the same case and then compare them. You can do this with string.upper or string.lower.
For example:

local str1 = "HeLlO WORlD"
local str2 = "hELLO WoRld"
local areEqual = str1:lower() == str2:lower()
print(tostring(areEqual)) --# Prints true
98Games_YT #3
Posted 12 July 2015 - 09:15 PM
Forgot to mention, but also something like saying with MoarPerpiherals to a chatbox ##CC:say:whatever. I don't know if this needs to find another string or not but thanks for the advice ._.