title: Ruby match and print multiple strings in data
body: <p>I have a hashes.xml on a location on the web. I want to parse it for the fields <code>name='hash'&gt;&lt;string&gt;78235A2449BA7188CBF95F7DD2D40A36&lt;/string&gt;</code>, the file has many fields with this pattern (the MD5 hash is only an example, they differ in the XML document), I want to get them all and print to stdout. As far as I get is to fetch the first occurence and print it out then I'm stuck.</p>
  
  <pre><code>for locale in (locales)
    while hash.nil? do
      headers = {
        'Host' =&gt; server,
        'Content-Type' =&gt; 'application/x-www-form-urlencoded',
        'Content-Length' =&gt; locale.length.to_s,
      }
  
      resp, data = http.post(path, locale, headers)
  
      # Extract the hash
      data =~ /name='hash'\&gt;\&lt;string\&gt;([A-F0-9]+).*\&lt;\/string\&gt;/m
      hash = $1
      mylocale = locale
      break if hash.nil?
    end
  end
  
  if hash.nil?
    puts "ERROR"
    exit(1)
  end
  
  puts "Hash: "+hash
  </code></pre>