title: Regex to extract iso code in a string in ruby
body: <pre><code>image_basename = 'fr-ca-test.png'
  
  Langs = {'ca', 'fr-CA', 'en-CA'}
  
  Langs.each do |locale_code|
    return locale_code /(\b|\_|-)#{locale_code}(\b|\_|-)/i.match(image_basename)
  
    end
  end
  </code></pre>
  
  <p>When the filename contains fr-CA or en-CA. I would like to returns fr-CA not Ca.</p>
  
  <p>How I can fix my regex?</p>