Is there a String Match OR Value?

Hello. I am trying to find if a player’s name begins with one of several letters. Is there an OR value I can use for the pattern matching? Otherwise I will just check each letter individually. Ultimately I am trying to make a sound play for 50% of the players and another sound for the other 50% and do this consistently (rather than at random). I realize this is probably a stupid way to do this but it’s what I thought of. Here’s what I have for matching one letter:

if string.match(playerName, “^t”) then

I tried using the + value at the end but that didn’t work. I have changed the player’s name to lower to take care of case values.

Thanks everyone.

Use string.find with square brackets for pattern matching…

local startsWith = "[AaBbCc]"
print("Charlie", string.find("Charlie", startsWith) == 1)  -- prints true
print("Dave", string.find("Dave", startsWith) == 1) -- prints false
1 Like