Created
September 26, 2011 11:00
-
-
Save hellboy81/1242014 to your computer and use it in GitHub Desktop.
Пример парсинга телефонных номеров
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.i18n.phonenumbers.* | |
import com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency | |
def phone_str = 'мой телефон - 4 95/9 87- 8 90-7' | |
phone_str += 'сотовый: 8/9031605612, я сейчас в командировке' | |
phone_str += '- Мой номер в Сан-Франциско 1(415)-42 577-58' | |
def phoneUtil = PhoneNumberUtil.getInstance() | |
for (cc in ["RU", "US"]) { | |
println "---------------------------------------------------------------" | |
def numbers = phoneUtil.findNumbers(phone_str, cc, Leniency.POSSIBLE, 10) | |
for (PhoneNumberMatch pnm in numbers) { | |
println pnm // где были найдены номера телефонов | |
def pn = pnm.number | |
println cc | |
println phoneUtil.formatOutOfCountryCallingNumber(pn, "RU") | |
println phoneUtil.getNumberType(pn) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment