简体   繁体   中英

extracting (international) phone numbers from text

I am looking for a way of extracting international phone numbers from text.

In other words, inputting the text below:

"this test +44 (0) 7961617600 Reconfirmation Notes Transfer to London train station (Mon, Apr 25) Pax : 45 + 1 BM Coaches Confirm +32 (020) 9948 7711 - Gaynor Reconfirmation is required by Apr 23. \\n\\nConfirmed with on at Day 4 : Monday, April 25, 2011 (Sun, Apr 24)"

would output: +44 (0) 7961617600 +32 (020) 9948 7711

Thank you

I'm not sure what you are using, but you might be able to just grep all the numbers from textfiles in a directory.

If the + will always be there it can be an anchor. In vim something like this could get the numbers in a folder, but it is loose

:lvim /+\d\{1}\([0-9 ()]\{9,}\)\d\{1}/gj *.txt

if you're sure there will be a (123) piece this could tighten it up

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM