title: A little more help for "Regex that match any character inside a parenthesis"
body: <p>I asked a related question <a href="https://stackoverflow.com/questions/24135006/regex-that-match-any-character-inside-a-parenthesis">on this thread</a>, and it helped me very much.</p>
  
  <p>I used this code:</p>
  
  <pre><code>function extractUsers(usersArray) {
      var i; // loop counter
      for (i = 0; i &lt; usersArray.length; i++) {
  
          if (/\(([^)]+)\)/.test(usersArray[i])) {
              // retrieves the user id from strings like "name (ID)"
              usersArray[i] = RegExp.$1;
              console.log('in the regexloop ' + i + ' of ' + usersArray.length + ' and test. current value: ' + usersArray[i]);
          }
          //console.log('the cleaned usersArray ' + usersArray);
      }
      return usersArray;
  }
  </code></pre>
  
  <p>For the user array: "Carin Nilsson-Thorell (CARIN.NILSSON-T),Maria Bengzon (MARIA.BENGZON),Therese Rick (THERESE.RICK),Inti van Eck (IPEINTECK)"</p>
  
  <p>the console log showed:</p>
  
  <pre><code>selected is Carin Nilsson-Thorell (CARIN.NILSSON-T),Maria Bengzon (MARIA.BENGZON),Therese Rick (THERESE.RICK),Inti van Eck (IPEINTECK)
  in the regexloop 0 of 4 and test. current value: CARIN.NILSSON-T
  in the regexloop 1 of 4 and test. current value: MARIA.BENGZON
  in the regexloop 2 of 4 and test. current value: THERESE.RICK
  in the regexloop 3 of 4 and test. current value: IPEINTECK
  extracted selected is CARIN.NILSSON-T,MARIA.BENGZON,THERESE.RICK,IPEINTECK
  </code></pre>
  
  <p>Which is exactly what I hoped for.
  But when the user array was just one user, "Inti van Eck (IPEINTECK)"
  the console log showed </p>
  
  <pre><code>selected is Inti van Eck (IPEINTECK)
  extracted selected is Inti van Eck (IPEINTECK)
  </code></pre>
  
  <p>So it seems it doesn't even enter the "if" statement? How come? </p>
  
  <p>I even tried <a href="https://regex101.com/" rel="nofollow noreferrer">https://regex101.com/</a> and there it works ok...</p>
  
  <p>I also tried the /(?&lt;=()[^)]*(?=))/ version, but that threw some error about the ? (Forgot to capture that error. Trying to reproduce it now, throws me other errors - I'll add the error text as soon as I can...)</p>
  
  <p>I am still trying to learn all I can about JavaScript, but I do stumble.</p>
  
  <h2>Edit</h2>
  
  <p>This is the "parent function" that calls the extractUsers function: </p>
  
  <pre><code>    function assignStepUsers() {
      var element = document.getElementById('mastercontrol.route.stepnumber');
      var stepNumber = element.value;
      console.log('running form assignStepUsers. stepNumber is ' + stepNumber);
      var selected = []; // array. holds the current value of users within a set of statements. set to empty for each stepNumber run.
      var i; //loop counter
      var pad = "00"; //size of id number
      var id; // id number of cause
      var counter; // what thing are we counting
      var selector; // what elements to select and count
      var nr; // how many things are launched (document.getElementById(counter).value)
      var things; // how many things in tota l (document.querySelectorAll(selector))
      var owner; // holds the current task owner within a set of statements
      var field; // the select field that holds all users of a step, with selected users highlighted
      var end; // length of field, for loop end.
  
      //var step2Users, step3Users, step4Users, step5Users, step6Users, step7Users, step8Users, step9Users, step10Users, step11Users, step12Users;
      // for preview, add "|| stepNumber == 0 || NaN(stepNumber)" after "stepNumber == 1" inside parenthesis
      if ((stepNumber == 1 ) &amp;&amp; (document.getElementById('mastercontrol.set.CAPA_Owner').value !='' &amp;&amp; document.getElementById('mastercontrol.set.CAPA_Coordinator').value != '')) { // removed || stepNumber == 0 || NaN(stepNumber), for troubleshooting/form preview only
          console.log('assignStepusers for Step 1 . selected CAPA Owner = ' + document.getElementById('mastercontrol.set.CAPA_Owner').value +  ' selected CAPA Coord = ' + document.getElementById('mastercontrol.set.CAPA_Coordinator').value);
  
          // assign QM and CAPA owner to step 2, 6, 8, 10, 12
  
          // find all content of the QM role field (QMOptions), then push values into array (QM)
          var QMOptions = document.getElementById('mastercontrol.role.QM').querySelectorAll('option');
          console.log('QMOptions length = ' + QMOptions.length);
          var QM = []; // array for all the QM users
          var oneQM; // the current QM user of the field
          for (i = 0; i &lt; QMOptions.length; i++) {
              oneQM = QMOptions[i].value;
              QM.push(oneQM);
              console.log('QM is now ' + QM);
          }
  
          selected = QM;
          console.log('selected is ' + selected);
  
          var capaOwner = document.getElementById('mastercontrol.set.CAPA_Owner').value;
          selected.push(capaOwner);
          console.log('selected is ' + selected);
  
          extractUsers(selected);
          console.log('extracted selected is ' + selected);
          sortUsers(selected);
          console.log('sorted selected is ' + selected);
  
          setStepUsers('mastercontrol.route.stepusers.step2', selected);
          setStepUsers('mastercontrol.route.stepusers.step6', selected);
          setStepUsers('mastercontrol.route.stepusers.step8', selected);
          setStepUsers('mastercontrol.route.stepusers.step10', selected);
          setStepUsers('mastercontrol.route.stepusers.step12', selected);
  
          // assign ONLY capa owner to step 4 
          selected = capaOwner; // QM users are removed.
          console.log('selected is ' + selected); 
          extractUsers(selected);
          // no need for sortUsers, only one in array.
          console.log('extracted selected is ' + selected);
          setStepUsers('mastercontrol.route.stepusers.step4', selected);
  
          //assign CAPA Coordinator to 3,5,7,9,11
          var capaCoord = document.getElementById('mastercontrol.set.CAPA_Coordinator').value;
          selected = capaCoord;
          console.log('selected is ' + selected);
          extractUsers(selected);
          // no need for sortUsers, only one in array.
          console.log('extracted selected is ' + selected);
          setStepUsers('mastercontrol.route.stepusers.step3', selected);
          setStepUsers('mastercontrol.route.stepusers.step5', selected);
          setStepUsers('mastercontrol.route.stepusers.step7', selected);
          setStepUsers('mastercontrol.route.stepusers.step9', selected);
          setStepUsers('mastercontrol.route.stepusers.step11', selected);
      }
  }
  </code></pre>