title: how to correctly highlight words using original javascript?
body: <p>I am trying to highlight all words from search text using other <a href="http://jsbin.com/ebucaz/108/edit?html,js,output" rel="nofollow noreferrer">people's code</a></p>
  
  <p>The JavaScript code is here:</p>
  
  <pre><code>var s = document.querySelector('input[type="search"]'),
      p = document.querySelector('p'),
      find = function(){
          var words = p.innerText.split(' '),
              i = words.length,
              word = '';
  
          while(--i) {
              word = words[i];
              if(word.toLowerCase() == s.value.toLowerCase()){
                  words[i] = '&lt;span class="highlight"&gt;' + word + "&lt;/span&gt;";
              }
              else{
  
              }   
          }
  
          p.innerHTML = words.join(' ');
      }
  
  s.addEventListener('keydown', find , false);
  s.addEventListener('keyup', find , false);
  </code></pre>
  
  <p>However, in this code if want to search some words end with '.', it won't give me correct content. I figure out, it is caused by <code>var words = p.innerText.split(' ')</code> however if I used <code>split(/\b(\w+)\b/g)</code> it will cause the extra space. 
    How can I use right regular expression to accomplish this using original js? </p>