title: bash script to extract ALL matches of a regex pattern
body: <p>I found this but it assumes the words are space separated.</p>
  
  <pre><code>result="abcdefADDNAME25abcdefgHELLOabcdefgADDNAME25abcdefgHELLOabcdefg"
  
  for word in $result
  do
      if echo $word | grep -qi '(ADDNAME\d\d.*HELLO)'
      then
          match="$match $word"
      fi
  done
  </code></pre>
  
  <p>POST EDITED</p>
  
  <p>Re-naming for clarity:</p>
  
  <pre><code>data="abcdefADDNAME25abcdefgHELLOabcdefgADDNAME25abcdefgHELLOabcdefg"
  for word in $data
  do
      if echo $word | grep -qi '(ADDNAME\d\d.*HELLO)'
      then
          match="$match $word"
      fi
  done
  echo $match
  </code></pre>
  
  <p><em>Original left so comments asking about <code>result</code> continue to make sense.</em></p>