lib/phonelib/phone_analyzer_helper.rb in phonelib-0.6.23 vs lib/phonelib/phone_analyzer_helper.rb in phonelib-0.6.24
- old
+ new
@@ -100,10 +100,11 @@
#
# * +data+ - country data hash
# * +country_optional+ - whether to put country code as optional group
def full_regex_for_data(data, type, country_optional = true)
regex = []
+ regex << '0{2}?'
regex << "(#{data[Core::INTERNATIONAL_PREFIX]})?"
regex << "(#{data[Core::COUNTRY_CODE]})#{country_optional ? '?' : ''}"
regex << "(#{data[Core::NATIONAL_PREFIX_FOR_PARSING] || data[Core::NATIONAL_PREFIX]})?"
regex << "(#{type_regex(data[Core::TYPES][Core::GENERAL], type)})" if data[Core::TYPES]
@@ -131,10 +132,10 @@
# * +phone+ - phone number for parsing
# * +data+ - country data
def phone_match_data?(phone, data, possible = false)
country_code = "#{data[Core::COUNTRY_CODE]}"
inter_prefix = "(#{data[Core::INTERNATIONAL_PREFIX]})?"
- return unless phone.match cr("^#{inter_prefix}#{country_code}")
+ return unless phone.match cr("^0{2}?#{inter_prefix}#{country_code}")
type = possible ? Core::POSSIBLE_PATTERN : Core::VALID_PATTERN
phone.match full_regex_for_data(data, type, false)
end