title: How do I figure out the indexes of where a string was split?
body: <p>I’m using Rails 4.2.7 (Ruby 2.3).  I use the following to split a string based on a regular expression</p>
  
  <pre><code>my_string.split(/\W+/)
  </code></pre>
  
  <p>My question is, how can I get an equivalent array of numbers in which each number represents the index of where the splits occurred?  If no splits occurred, I would expect the array to only contain an element with “-1”.</p>