title: Sed: Substitute letters on certain positions
body: <p>I have a file with the structure:</p>
  
  <pre><code>N1H3O1 C2H2
  C1H4 H201
  C1H1N1 N1H3
  C2N1O1P1H3 P5
  </code></pre>
  
  <p>What I am trying to do is to count the sum of coefficients in each of the formulae. Thus, the desire output is:</p>
  
  <pre><code>1+3+1 5 2+2 4
  1+4 5 2+1 3
  1+1+1 3 3+1 4
  2+1+1+1+3 8 5 5
  </code></pre>
  
  <p>What I did is a simple replacement of each letter with "+" and then deleting the first " +". </p>
  
  <p>I however would like to know how to do it in a more proper way in sed, using branch and flow operators.  </p>