title: How to find indices of groups in JavaScript regular expressions match?
body: <p>When I write a regular expression like:</p>
  
  <pre><code>var m = /(s+).*?(l)[^l]*?(o+)/.exec("this is hello to you");
  console.log(m);
  </code></pre>
  
  <p>I get a match object containing the following:</p>
  
  <pre><code>{
    0: "s is hello",
    1: "s",
    2: "l",
    3: "o",
    index: 3,
    input: "this is hello to you"
  }
  </code></pre>
  
  <p>I know the index of the entire match from the <code>index</code> property, but I also need to know the start and end of the groups matched. Using a simple search won't work. In this example it will find the first 'l' instead of the one found in the group.</p>
  
  <p>Is there any way to get the offset of a matched group?</p>