in reply to Bad Language In Contact Messages

Can someone suggest a solution or tell me what I'm doing wrong?

The exit needs to be inside the if.

For a more efficient way to do what you're doing without foreach, see my tutorial Building Regex Alternations Dynamically.