如何从文本文件中获取电话号码 [英] How can I fetch phone numbers from a text file

查看:95
本文介绍了如何从文本文件中获取电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我有一个包含文字和数字的文件。

我想从该文件中逐个获取所有联系号码。 (例如:91-474-2299,9999,2500013)等...

有没有办法让它成为朋友,,,

文件可能大或中等...甚至它可以是html文件...

Hi friends,
I have a file with text and numbers in it.
I want to fetch all the contact numbers one by one from that file. (Eg: 91-474-2299, 9999, 2500013) etc...
Is there any way to get it friends,,,
file might be large or medium... or even it can be html files...

推荐答案

你的例子暗示(我可能错了)联系人是'逗号分隔'因此你可以阅读文件逐行和(对于每一行)使用逗号作为 String.Split 方法中的分隔符获取联系人。
Your example suggests (I may be wrong) contacts are 'comma separated' hence you could read the file line-by-line and (for each line) obtain the contacts using the comma as separator in the String.Split method.


您可以使用 RegEx类 [ ^ ] 电话号码模式 [ ^ ]。但请记住,不同国家/地区存在不同的电话号码 [ ^ ]。有关详细信息,请参阅国家公约 [ ^ ]。



因此,此集合中只有一个(可能是两个)数字数字: 91-474-2299,9999,2500013 可以是电话号码。这就是为什么我认为 Split 函数 - 在这种情况下 - 是不够的。
You can use RegEx class[^] with phone number pattern[^]. But remember, there exist different phone numbers for different countries[^]. For further information, please, see national conventions[^].

So, only one (maybe two) number from this set of numbers: 91-474-2299, 9999, 2500013 could be a phone number. That's why i'm thinking that Split function - in this case - is not enough.


这篇关于如何从文本文件中获取电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆