title: javascript regex exec and replace
body: <p>I want to replace the regex matched str with some other string after calling function. 
  Can't find any method for the same .. </p>
  
  <p>Consider </p>
  
  <pre><code>var str = "someRegex ajfgdgkjdljlgdgjlrm someRegeeeeex dfdsfj";
  var re = /someReg(.*?)x/g;    
  while ((m = re.exec(str)) != null) {
     // m= ["someRegex", "e"]
     // m= ["someRegeeeeex", "eeeee"]
  
  // I WANT  TO REPLACE THE MATCHED WITH AFTER CALLING A FUNCTION 
  // lets say someRegex with someRegex1 and someRegeeeeex with someRegeeeeex5
               }
  </code></pre>
  
  <p>Note : i don't want to use str replace since it will not be give  me the correct solution. lets say replacing someRegex with someRegex1 and someRegeeeeex with someRegeeeeex5 . USING str.replace will replace first one again and again.</p>