re = /^\d+(?:\h+[A-Z][a-z.]+)+$/m
str = 'Allow these
123 Main St
123 Main St.
1504 Eagle Point Way
1024 McKinley Ave NW
7813 Peña Blanca Street
Don’t allow these
123 MAIN ST
123 main st
1504 EAGLE point wAy'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html