Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How could I find a certain word in a whole string?

Asked by 4 years ago

For example - "I like apples and pie" how can I find "apples" and nothing else of the string?

2 answers

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
4 years ago
local str = "Hello World!"

local match = string.match(str, "World!")
-- This would return either "World!" or nil.
Ad
Log in to vote
1
Answered by 4 years ago
local string = "I like apples and pie"
if string:find("apples") then
    --stuff
end

i hope this works

Answer this question