title: Simple JS regex replace.
body: <p>I am struggling trying to create a really simple RegExp. (probably lacking some hours of sleep).</p>
  
  <p>I just have has an input this string : /users/10/contracts/1
  My regex is this one : /users/(\w+)/contracts/(\w+)/</p>
  
  <p>I want to replace all matches with this kind of string : /users/{variable1}/contracts/{variable2}</p>
  
  <p>Here is my complete source code : </p>
  
  <pre><code>var customRegex = "/users/(\\w+)/contracts/(\\w+)";
    var i =0;
    var finalUrl = "/users/1234/contracts/5678".replace(new RegExp(customRegex, 'gi'), function myFunction(x, y){
      return "{variable" + i + "}"; 
    });
  
    console.log(finalUrl);
  </code></pre>
  
  <p>Could you please help me?</p>
  
  <p>I wish you a nice day and thank you for your help.</p>