title: Iterate through elements with similar IDs
body: <p>I want to get the <code>id</code> of a single <code>&lt;span&gt;</code> element during iteration.</p>
  
  <p>Example scenario:</p>
  
  <p>I have a few <code>id</code>s which start with <code>AAA</code> and end with <code>BBB</code>. The middle characters can vary:</p>
  
  <pre><code> &lt;span id="AAA-LS-BBB"&gt;hi1&lt;/span&gt;
   &lt;span id="AAA-LAS-BBB"&gt;hi2&lt;/span&gt;
   &lt;span id="AAA-LBS-BBB"&gt;hi3&lt;/span&gt;
   &lt;span id="AAA--LCS--BBB"&gt;hi4&lt;/span&gt;
  </code></pre>
  
  <p>Here, first 3 digits of span id and last 3 digits of span id is same...only in middle it will vary. I want to generalized method to know ...each id using... $("#id").attr("id")
  so, here
   I am trying to find out iteration like below,
  I want to write one iterator method to get the current id</p>
  
  <pre><code>$("span[id^='AAA-***-BBB']").each(function(){
      var a = $("this").attr("id");
  });
  </code></pre>
  
  <p>Hope my requirements are clear.
  how ti use regular expression here.. to find out id? </p>