search words highlight code not working correct
<p>i have used a piece of jQuery to highlight the search results, it works nice but i want to match all single words not the whole phrase that i have entered, if i search for "lorem ipsum dolor" it looks for this matching phrase, but i want that the script highlightes all of the single words and not the whole phrase</p>

<p>heres my jQuery code</p>

<pre><code>    $("#main-search-input").bind('keyup', function(e){
        var text = $.trim($(this).val());
        if(text !== '' &amp;&amp; text !== ' '){
          var pattern = new RegExp(text, "gi");
        }
        $('.sr-results a').each(function(i){
            var str = this;
            var orgText = $(str).text();
                orgText = orgText.replace(pattern, function($1){
                return "&lt;b class='sr-highlight'&gt;" + $1 + "&lt;/b&gt;";
            });
         $(str).html(orgText);
        });   
    }); 
</code></pre>
