Non alphanumeric characters replaced with a single space
<p>Here's the thing I'm trying to get a search engine to pick up names entered as Doe J instead of Doe, J. </p>

<p>Here is my code:</p>

<pre><code>$sql_where = array();

if (isset($_GET['name'])) {

    echo "Searched: {$_GET['name']}&lt;br&gt;";

    $names = explode(' ', trim(preg_replace('/ +/', ' ', $_GET['name'])));
    $names_cnt = count($names);

    if (2 == $names_cnt) {

        foreach ($names as $name_idx =&gt; $name) {

            if (($name_idx+1) == $names_cnt) {
                // last one
                $sql_where[] = "
                    (full_name like '% {$name}%')
                    ";
            } else {
                // first one
                $sql_where[] = "
                    (full_name like '{$name}%')
                    ";
            }
        }
    } else {

        $sql_where[] = "
            (full_name like '" . $DB-&gt;cleanString($_GET['name']) . "%')
            ";
</code></pre>

<p>I've tried <code>/[^a-zA-Z0-9 ]/</code> and a few other variations that have been unsuccessful. </p>
