title: Better way to extract phone number and reformat?
body: <p>Phone number data in various formats (I've chosen these because the data coming in is unreliable and not in expected formats):</p>
  
  <pre><code>+1 480-874-4666
  404-581-4000
  (805) 682-4726
  978-851-7321, Ext 2606
  413- 658-1100
  (513) 287-7000,Toll Free (800) 733-2077
  1 (813) 274-8130
  212-363-3200,Media Relations: 212-668-2251.
  323/221-2164
  </code></pre>
  
  <p>My Ruby code to extract all the digits, remove any leading 1's for the USA country code, then use the first 10 digits to create the "new" phone number in a format desired:</p>
  
  <pre><code>  nums = phone_number_string.scan(/[0-9]+/)
    if nums.size &gt; 0
      all_nums = nums.join
      all_nums = all_nums[0..0] == "1" ? all_nums[1..-1] : all_nums
      if all_nums.size &gt;= 10
        ten_nums = all_nums[0..9]
        final_phone = "#{ten_nums[0..2]}-#{ten_nums[3..5]}-#{ten_nums[6..9]}"
      else
        final_phone = ""
      end
      puts "#{final_phone}"
    else
      puts "No number to fix."
    end
  </code></pre>
  
  <p>The results are <strong>very good</strong>!</p>
  
  <pre><code>480-874-4666
  404-581-4000
  805-682-4726
  978-851-7321
  413-658-1100
  513-287-7000
  813-274-8130
  212-363-3200
  323-221-2164
  </code></pre>
  
  <p><strong>But, I think there's a better way. Can you refactor this to be more efficient, more legible, or more useful?</strong></p>