I am trying to make a custom chat and I want a word blacklist (words that can't be said so they get replaced with #'s), I have tried and it worked but when it did it it also changed the whole message's case and I couldn't see any way around this. This is an example of what I did:
v = "LOL"
msg = "Hi, I like to LOL because I can"
print(string.gsub(string.lower(msg),string.lower(v),string.rep("#",string.len(v))))
-- The output is: hi, i like to ### because i can
My problem is that it changes the whole message to lower case and if I try to fix it by not changing the message to lower case this is the script I could use:
v = "lol"
msg = "Hi, I like to LOL because I can"
print(string.gsub(msg,string.lower(v),string.rep("#",string.len(v))))
-- The output is: Hi, I like to LOL because I can
My problem here is that if the message has the word but in a different case and the only way I can think of fixing this is having a table of all the possible cases but if I do a long word like intermediate it has 100's of possibilities and that's just one word. If you know a quick way to do this please help me!

4 comments
I think I might know the answer to my own question, I'll just test my theory but please if you know post the answer!
string.find(msg:lower(),v:lower()) will help you here. Find the part of the string found to be v and change it to # or do you code, and only lower case that part of the string. For more Info: http://wiki.roblox.com/index.php?title=String.match#string.find
That's exactly what my theory was, I was going to do it but I thought it might not work so continued with my main script. Now you have said the same thing I will test it, if you post that as an answer I will vote it up and accept answer to give you some reputation.
I'll try to find a solution for you and then test it in Studio. However, my answer will not be posted for at least 5 from now. Sorry; I'm in school. However, if I were you, I would try to do something that finds all matches of "LOL" in any case in a string, then use string.sub to replace them with #'s. I'm not sure if that can be done, because as said earlier, I can't test in Studio currently.