Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would i find certain letters in a string?

Lets say I have two values, "Baby", and "Dog". What I want to do is find both of those strings in one name in lighting, as in "Baby Dog". The thing is, I don't know how to find certain letters in strings to be able to do this.

1 comment

2

You can use find function. string.find(originalstring,'Baby') or originalstring:find('Baby')

1 answer

✓ Accepted answer

You just use string.match. It matches strings. If it finds a match, it returns that match; otherwise it returns nil.

local str = "Baby Dog"
print( str:match("Baby") ) --> Baby
print( str:match("qwerty") ) --> nil

You can also use string patterns for less specific matching.

This discussion is preserved as it was. New answers, comments, and votes are closed.