So, let’s say I have this string.
local String = "dfhqfqu9fhHelloigjruig"
I want to print the part of the string which has the word ‘Hello’, and ignore all of the other parts of the string.
Is this possible?
So, let’s say I have this string.
local String = "dfhqfqu9fhHelloigjruig"
I want to print the part of the string which has the word ‘Hello’, and ignore all of the other parts of the string.
Is this possible?
Yes, you can use String.match() function like Sonde mentioned or String.find() if you want to locate where a specific words starts and ends in a string. Also if that word is consistently in a particular place, you can use String.sub(“dfhqfqu9fhHelloigjruig”, 10, 14) - assuming you know the position.
Either you are looking for string.match which is below or you are trying to find where it says that which is, but you can also use it just to figure out if it was sent with this below
string.find(String,"Hello")
-- Will return tuple of two numbers, the starting number is which letter starts at
-- and the ending letter in the string, e.g "Hello World" is 1,5
local stringStart, stringEnd = string.find(String,"Hello")
print(stringStart, stringEnd)
if string.find(String,"Hello") ~= nil then
-- Code
end
Thank you guys for the help! I appreciate it.