Johnny2 Posted March 10, 2013 Report Share Posted March 10, 2013 I'm trying to use preg_match() properly to search a string for any of several words. Basically I'm testing if a string contains a naughty word. This doesn't seem to work: preg_match("/word1/word2/word3/",$string_to_examine); What am I missing? Quote Link to comment Share on other sites More sharing options...
Strider64 Posted March 10, 2013 Report Share Posted March 10, 2013 I'm trying to use preg_match() properly to search a string for any of several words. Basically I'm testing if a string contains a naughty word. This doesn't seem to work: preg_match("/word1/word2/word3/",$string_to_examine); What am I missing? preg_match("/word/i", $string_to_examine); // The i allows for upper & lower case words..... I personally do this : $user_edits = str_ireplace($patterns, $replacements, $text); //replace it Quote Link to comment Share on other sites More sharing options...
Johnny2 Posted March 11, 2013 Author Report Share Posted March 11, 2013 preg_match("/word/i", $string_to_examine); // The i allows for upper & lower case words..... I personally do this : $user_edits = str_ireplace($patterns, $replacements, $text); //replace it Thanks for your reply Strider. I am not looking to replace anything. I simply want to test if there is one (or more) swear-words in the string. I know how to use preg_match to test for a single swear-word. I just need to know how to write the command so that I can look for many swear words at the same time. Do you know how to do this? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.