title: Javascript RegEx .match() with $1, $2, etc. selectors
body: <p>I'm trying to do a simple RegEx match in Javascript and am having trouble figuring out the logic. Basically I have a function in the source code that I'm converting to a string. It's sort of complex but part of the function (the array part) is being generated by ASP server side code so the function is always different, depending on the user that visits the page. It's not really relevant I guess, but good to know why I'm doing and what I'm trying to accomplish. The function is this:</p>
  
  <pre><code>function Choose_My_Saved_Billing(arg_index) {
  switch(arg_index) { 
      case 1 : {
           ChosenCopy(document.OnePageCheckoutForm, 'billing', 'Test', 'Name', '', '123 Main Dr.', 'none', 'Los Angeles', 'CA', '90046', 'USA', '3105551234', '',''); 
           document.getElementById('span_v1state_dropdown').style.display='none'; document.getElementById('span_v1state_textbox').style.display='block'; break }
      }
  
      if (arg_index &gt; 0) { 
          document.getElementById('span_remove_selected_billing').style.display='block'; 
      } else {
          document.getElementById('span_remove_selected_billing').style.display='none'; 
      }
      if (typeof v65DecideCopyBillingToShipping == 'function') { 
          v65DecideCopyBillingToShipping(true);
      }
  }
  </code></pre>
  
  <p>I'm trying to just get those values that are in the array after 'OnePageCheckoutForm' and put them into an array I can access with other code. The string I generate is this:</p>
  
  <pre><code>var function_string = Choose_My_Saved_Billing.toString();
  var matches = function_string.match(/(')(.*?)(',)/g);
  </code></pre>
  
  <p>All I want is the value from the $2 variable in the matching pattern. The only way to determine the values I want are ones that are in single quotes with a trailing comma (otherwise it would match the other variable values in the function like <code>span_remove_selected_billing</code>) but I don't want the single quotes or commas in the resulting matches.</p>
  
  <p>Is there a way to just getting the second parentheses in the match statement?</p>
  
  <h2>EDIT</h2>
  
  <p>I tried this to try negative lookaheads but I guess I'm having trouble because there is no negative look behind in Javascript:</p>
  
  <pre><code>(')(.*?)(?=',)
  </code></pre>
  
  <p>It's close but not quite there? I think it's the first part of the statement I'm having a problem with...</p>
  
  <p>Thanks for your help!</p>