Most audios that have been amplified have 'loud' in the title. I have a boombox and I want to prevent these audios being played. I have made it so that if it finds 'loud' in the title or description then it gets refused. The ROBLOX studio search (CTRL+F) lets you search for a whole word only so it can't be included in a word, as 'loud' is in 'cloud'. I can't think of a way to do this, my current code searches for the word, but not just the word, so these are the results when searching for loud:
'cloud' --> true 'cloud.' --> true 'louder' --> true 'louder.' --> true 'loud' --> true 'loud.' --> true
But these are the results I want:
'cloud' --> false 'cloud.' --> false 'louder' --> false 'louder.' --> false 'loud' --> true 'loud.' --> true
I can't work out a method for achieving this, I hope you can help!
You should 1st look at Character Classes as you will need to understand how string patterns work.
The main problem is knowing when a new word has started which is why cloud
would match.
The pattern %f[%l]loud%f[%L]%.?
this will look for the whole word loud in lower case %l
I have also added '%.?% which will look for 0 or one match of the literal '.'
My testing:-
local test = { 'loud', 'loud.', 'Loud', 'Loud.', ' loud', ' loud.', ' Loud', ' Loud.', ' loud ', ' loud. ', ' Loud ', ' Loud. ', 'cloud', 'a loud', 'very' } local pattern = '%f[%l]loud%f[%L]%.?' for i, str in pairs(test) do local match = str:match(pattern) if match then print('String found index', i,'String ', str, 'Res', match) else print('Did not find', str) end end
I hope this helps.
Hey, this is gonna be a short answer because, I literally have like 1 minute but, here are the scripts that I managed to come up with: If you don't understand anything please post it in the comment below.
-- Won't print anything local matching = "loud" local name = "cloud" for w in string.gmatch(name, matching) do if #w == #name then print(w) end end -- Will print "loud" local matching = "loud" local name = "loud" for w in string.gmatch(name, matching) do if #w == #name then print(w) end end
Thank you for your time and I am sorry this is a really messy answer but, it should be helpful. Don't forget if you don't understand anything, comment below.
~~ KingLoneCat