title: javascript get substring of string at n of the same char
body: <p>I have the string:</p>
  
  <pre><code>"A1111A2222A3333A4444"
  </code></pre>
  
  <p>how do I get the string:</p>
  
  <pre><code>"A1111"
  </code></pre>
  
  <p>I need to be able to get it by specifying the number of 'A' chars from the end and removing this portion from the total string.</p>
  
  <p>EDIT:</p>
  
  <p>I have a large string separated by the char 'A', for example:</p>
  
  <pre><code>"A11A22A33A44A55A66A77A88A99"
  </code></pre>
  
  <p>What I need is a function that will give me the substring from 0 to the index of n 'A' chars away. For example, getSubstring(3) would return:</p>
  
  <pre><code>"A11A22A33A44A55A66"
  </code></pre>