re = /(?:(f|F)((a|A)(X|x))?(?:\s?(\-|\:)?\s?))(?:\s?[0-9\+\.\(\)\/\\\-]\/?\\?\s?){7,30}(*SKIP)(*FAIL)|(?:\s?[0-9\+\.\(\)\/\\\-]\/?\\?\s?){7,30}/
str = 'PO BOX number 1234, CA - 3265 TEL: +1-200-200-2000 FAX: +1-200-200-2001
PO BOX number 1234, CA - 3265 Service: +1-200-200-2002 \\ +1-200-200-2022 F : +1-200-200-2003
PO BOX number 1234, CA - 3265 care: +1-200-200-2004 f : +1-200-200-2005
PO BOX number 1234, CA - 3265 fire: +1-200-200-2006 fax : +1-200-200-2007
PO BOX number 1234, CA - 3265 help: +1-200-200-2008 fax - +1-200-200-2009
PO BOX number 1234, CA - 3265 fax : (+123)-4567890 \\ (+123)-4567891
(?:(f|F)((a|A)(X|x))?'
# 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