title: How to manipulate regex named capturing groups
body: <p>I'm trying to use a capture group to replace data with itself, plus a manipulation to a number in it. This is the text to work on:</p>
  
  <pre><code>firstGroup1
  firstGroup33
  </code></pre>
  
  <p>My goal is to replace any number of group with itself + 1 to get, for example:</p>
  
  <pre><code>firstGroup2
  firstGroup34
  </code></pre>
  
  <p>This currently is the code to display the two different capture groups:</p>
  
  <pre><code>data = data.replace(/(firstGroup)([1])/gms, '$1 $2')
  </code></pre>
  
  <p>and this is a failed attempt to do what I want, for sakes of understanding the question:</p>
  
  <pre><code>data = data.replace(/(firstGroup)([1])/gms, '$1' + $2+1
  </code></pre>
  
  <p>How can I perform this number addition in nodeJS javascript? thank you!</p>
  
  <p><strong>example 2:</strong></p>
  
  <p>text:</p>
  
  <pre><code>.method public constructor &lt;init&gt;()V
      .locals 2
  </code></pre>
  
  <p>failed code:</p>
  
  <pre><code>data = data.replace(/(constructor \&lt;init\&gt;[(][)]V.............)(..)/gms, (_, first, num) =&gt; first + (Number(num) + 1));
  </code></pre>