title: substr giving wrong value - javascript
body: <p>For some reason, when I do the following:</p>
  
  <pre><code>var input = 'focus name (tag1 tag2 OTHER,STUFF) focus 2 (MORE)';
  var openParen = input.indexOf('(');
  var closeParen = input.indexOf(')');
  var parenStr = input.substr(openParen + 1, closeParen - 1);
  </code></pre>
  
  <p>I expect <code>parenStr</code> to equal <code>"tag1 tag2 OTHER,STUFF"</code>.</p>
  
  <p>Instead, I'm getting it as <code>"tag1 tag2 OTHER,STUFF) focus 2 "</code>. Can anyone explain this to me?I feel like I'm going crazy haha, I've tried manually entering:</p>
  
  <pre><code>input.substr(openParen + 1, 32)
  </code></pre>
  
  <p>but it gives the exact same result. I've used <code>.substr()</code> tons of times before and never run into this kind of error before, I must be missing something.</p>