title: Find white space in a string back from an index position
body: <p>Lets say I have a string, but the text could be anything!</p>
  
  <blockquote>
    <p>This is a test case</p>
  </blockquote>
  
  <p>The 'boundary' is the count after a space, this means the charIndex =</p>
  
  <p>(0) This 
  (5) is 
  (8) a 
  (10) test 
  (15) case</p>
  
  <p>The above means from (0) to (5) the word equals 'this '.</p>
  
  <p>If I wanted to know the word just used, I would need to <code>substr</code> start at <code>charIndex</code> and look backwards until <code>indexOf(' ')</code>      </p>
  
  <p>Example:  If I wanted to find the word just used at charIndex (10) how would I instruct javascript to look backwards until the next space and give me the word "a ".</p>
  
  <p>Is it possible to do this, with as little process time, using Javascript, or JQuery?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Instead of looking after the word and going back, I decided to achieve what I needed, I split the words and used each charIndex as a count.  Code follows:</p>
  
  <pre><code>var u = new SpeechSynthesisUtterance();
  var words = element.innerHTML.split(' ');
  var a = 0;
   u.text = element.innerHTML;
   u.lang = 'en-UK';
   u.rate = 0.7;
   u.onboundary = function(event) {
   console.log(words);
   element.innerHTML = element.innerHTML.replace(words[a], '&lt;strong&gt;' + words[a] + '&lt;/strong&gt;');
    a++;       
    }
  </code></pre>
  
  <p>But as this is not the questions answer, still the best answer to reverse search a string is that which is marked correct, although it still needs some work depending on the string structure.</p>