How do you locate something in a string? (Not about string.find())

How do we get the position of something in a string?
Note: I am aware of string.find(). What I’m asking is if you can locate a letter by numbers etc.

local String = "Hello! I am here!"
local StringFind = String.Find(String, "Hello!")

How do I find the position where “Hello!” is? Or is it currently impossible?

find actually returns the indices of where it starts and ends, so you should have all the information you need to determine its position in the string:

local startIndex, endIndex = String:find("Hello!")
--//Should print 1 and 6

It doesn’t seem to work for me, did I do something wrong?

local String = "Hello! I am here!"
local StringFind = string.find(String, "Hello!")
local startIndex, endIndex = string.match("Hello!")

@C_Sharper just had a typo, they mean string.find not string.match

1 Like