Jump to content
Old threads will finally start getting archived ×

MikeM-2468

Members
  • Posts

    6
  • Joined

  • Last visited

MikeM-2468's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This seems to work for what I need: $input = "xxxxssworxxxickle"; $wordlist = array("password", "pickle", "passwest", "wordgame", "swords", "orxxx"); $charactercheckcount = 5; $charactercheckcountoffset = $charactercheckcount-1; for($x = 0; $x < count($wordlist); $x++) { $wordlistitem = $wordlist[$x]; $wordlistitemlength = strlen($wordlistitem); $loop = 0; while ($loop < $wordlistitemlength-$charactercheckcountoffset) { $checkstring = substr($wordlistitem, $loop, $charactercheckcount); $match = strpos($input, $checkstring); if ($match) { echo "Match found"; exit(); } ++$loop; } }
  2. I'm going to see what I can do with the PHP based stuff. Since it's a small result, I might be able to do it with mb_substr(), mb_strpos() and mb_strlen().
  3. OK. In that case, what's the regex voodoo to get the match I need?
  4. Since regex won't work in the MySQL query, can I read all of the entries into an array and then match to the array with regex? The query won't be very large - maybe 10 results, growing by about 5 per year.
  5. I'm open to suggestions.
  6. I think I need to use a regex to match part of a string. I've used preg_match before but my brain hasn't grasped the intricacies of adding regex. For background, I'm grabbing input from a form then querying MySQL to see if there is a match in the database. I'm looking for a match of 5 consecutive characters. $input = "test12345"; $found_match = "west1298"; or $found_match = "test1278"; Is preg_match enough or do I need more?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.