re = /(\b(?:\w+)?\d+(?:\w+)?(?:[\-\/])?(?:\w+)?(?:\d+)?\b)/
str = 'Park Avenue number 100
Baker Street number 100
Baker Street 100
The bakery shop is located on 109-111 Wharfside Street
My mother\'s house is on 40-42 Parkway
My schoolmate lives in 25b-26 Sun Street
The apartment is located on R2-R3 City Quay
I live in 43a Garden Walk
I live in 6/7 Marine Road
I live in 10-12 Acacia Ave
I live in 4513 3RD STREET CIRCLE WEST
I live in 1/2 Fifth Avenue
number C3-H4 sawojajar Malang'
# 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