title: How to find indices of all occurrences of one string in another in JavaScript?
body: <p>I'm trying to find the positions of all occurrences of a string in another string, case-insensitive.</p>
  
  <p>For example, given the string:</p>
  
  <pre>I learned to play the Ukulele in Lebanon.</pre>
  
  <p>and the search string <code>le</code>, I want to obtain the array:</p>
  
  <pre><code>[2, 25, 27, 33]
  </code></pre>
  
  <p>Both strings will be variables - i.e., I can't hard-code their values.</p>
  
  <p>I figured that this was an easy task for regular expressions, but after struggling for a while to find one that would work, I've had no luck.</p>
  
  <p>I found <a href="http://www.java2s.com/Code/JavaScript/Language-Basics/UsingtheindexOfMethodtoFindAllOccurrencesoftheLettereinaSentence.htm" rel="noreferrer">this example</a> of how to accomplish this using <code>.indexOf()</code>, but surely there has to be a more concise way to do it?</p>