I was wondering if it’s possible to check if a word is in a string. Such as;
if 'something' is in 'something is happening!!!' then
Note: That won’t work. It’s just a concept idea.
I was wondering if it’s possible to check if a word is in a string. Such as;
if 'something' is in 'something is happening!!!' then
Note: That won’t work. It’s just a concept idea.
Fun fact, Python actually does it like that.
cool_string = "Hi lol"
if "lol" in cool_string:
print("yes")
But this isn’t about Python! In Lua you can use string.match
:
local cool_string = "Hi lol"
if cool_string:match("lol") then
print("yes")
end
It returns the actual match, otherwise nil
if there is no match.