title: regex camelize particular text inside string
body: <p>I have a next string: </p>
  
  <pre><code>  $scope.string = "User {{User Firstname}} &lt;/p&gt;&lt;p&gt;System {{Reported System Name}} &lt;/p&gt;&lt;p&gt;Desc {{Description}}&lt;/p&gt;&lt;ol&gt;&lt;/ol&gt;"
  </code></pre>
  
  <p>I'm trying to achieve next result: </p>
  
  <pre><code> $scope.string = "User {{userFirstname}} &lt;/p&gt;&lt;p&gt;System {{reportedSystemName}} &lt;/p&gt;&lt;p&gt;Desc {{description}}&lt;/p&gt;&lt;ol&gt;&lt;/ol&gt;"
  </code></pre>
  
  <p>With help of regex I can find necessary for camelize text</p>
  
  <pre><code>if ($scope.string.match(/\{\{(.*?)\}\}/g)){
         for (var i = 0; i &lt; $scope.string.match(/\{\{(.*?)\}\}/g).length; i ++){
               $scope.string.match(/\{\{(.*?)\}\}/g)[i] = camelizeBrackets($scope.string.match(/\{\{(.*?)\}\}/g)[i])
          }
    }
  </code></pre>
  
  <p>But the function <code>camelizeBrackets</code> which I have found <a href="https://stackoverflow.com/a/2970667/6524629">here</a> and modified to work with text inside curly braces doesn't work at all </p>
  
  <pre><code> function camelizeBrackets(str) {
       return str.replace(/\{\{(?:^\w|[A-Z]|\b\w|\s+)\}\}/g, function(match, index) {
          if (+match === 0) return "";
            return index === 0 ? match.toLowerCase() : match.toUpperCase();
         });
     }
  </code></pre>
  
  <p>Could anybody explain me what I'm doing wrong?</p>
  
  <p><a href="https://plnkr.co/edit/nIqtn9RbR0RJuRmkvjUO?p=preview" rel="nofollow noreferrer">My plunker</a></p>