title: Javascript Regex and getElementByID
body: <p>I'm trying to search for all elements in a web page with a certain regex pattern.</p>
  
  <p>I'm failing to understand how to utilize Javascript's regex object for this task. My plan was to collect all elements with a jQuery selector</p>
  
  <pre><code>$('div[id*="Prefix_"]');
  </code></pre>
  
  <p>Then further match the element ID in the collection with this</p>
  
  <pre><code>var pattern = /Prefix_/ + [0 - 9]+ + /_Suffix$/;
  //Then somehow match it. 
  //If successful, modify the element in some way, then move onto next element.
  </code></pre>
  
  <p>An example ID would be "Prefix_25412_Suffix". Only the 5 digit number changes.</p>
  
  <p>This looks terrible and probably doesn't work:</p>
  
  <p>1) I'm not sure if I can store all of what jQuery's returned into a collection and then iterate through it. Is this possible?? If I could I could proceed with step two. But then...</p>
  
  <p>2) What function would I be using for step 2? The regex examples all use String.match method. I don't believe something like element.id.match(); is valid?</p>
  
  <p>Is there an elegant way to run through the elements identified with a specific regex and work with them?
  Something in the vein of C#</p>
  
  <blockquote>
    <p>foreach (element e in
    ElementsCollectedFromIDRegexMatch) { //do stuff }</p>
  </blockquote>