Tweak jQuery highlighting script
<p>I got the following jQuery plugin to highlight query keywords in a string. It curretly highlight each query keyword found in the string, both exact word matches but also if the keywords are just a part of a longer word.</p>

<p>In the case of a user typing a query e.g. "I am a human" I would though like to avoid highlighting all the i's and a's in the string. How can I tweak this script to only highlight words of less than 3 chars if the match a whole word?
 I.d. if the highlighting tag is <code>&lt;b&gt;</code> the string <code>"I am a humanoid"</code> and the keywords are <code>I am a human</code> the function would output:</p>

<p><code>"&lt;b&gt;I&lt;/b&gt; &lt;b&gt;am&lt;/b&gt; &lt;b&gt;a&lt;/b&gt; &lt;b&gt;human&lt;/b&gt;oid"</code></p>

<p>instead of currently:</p>

<p><code>"&lt;b&gt;I&lt;/b&gt; &lt;b&gt;am&lt;/b&gt; &lt;b&gt;a&lt;/b&gt; &lt;b&gt;human&lt;/b&gt;o&lt;b&gt;i&lt;/b&gt;d"</code></p>

<pre><code>jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos &gt;= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 &amp;&amp; node.childNodes &amp;&amp; !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i &lt; node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};
</code></pre>
