title: AWK - add value based on regex
body: <p>I have to add the numbers returned by REGEX using awk in linux.</p>
  
  <p>Basically from this file:</p>
  
  <pre><code>123john456:x:98:98::/home/john123:/bin/bash
  </code></pre>
  
  <p>I have to add the numbers <code>123</code> and <code>456</code> using awk.
  So the result would be <code>579</code></p>
  
  <p>So far I have done the following:</p>
  
  <p><code>awk -F ':' '$1 ~ VAR+="/[0-9].*(?=:)/" ; {print VAR}' /etc/passwd</code></p>
  
  <p><code>awk -F ':' 'VAR+="/[0-9].*(?=:)/" ; {print VAR}' /etc/passwd</code></p>
  
  <p><code>awk -F ':' 'match($1, VAR=/[0-9].*?:/) ; {print VAR}' /etc/passwd</code></p>
  
  <p>And from what I've seen match doesn't support this at all.</p>
  
  <p>Does someone has any idea?</p>
  
  <p>UPDATE:
  it also should work for
  <code>john123</code> result - > <code>123</code>
  <code>123john</code> result - > <code>123</code></p>