【发布时间】:2016-06-16 09:52:30
【问题描述】:
我需要从 Resume.doc 文件中获取邮政编码。 但没有成功,,,
它使用静态字符串,我的意思是它验证静态字符串但无法解析 doc 文件中的邮政编码,
我正在分享我的代码...
protected void zipcodeGetter()
{
var path = "C:\\Users\\Jatinder\\Desktop\\LUCENE\\Resume\\Jeffrey.doc";
Document doc = new Document();
string html = File.ReadAllText(path);
using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
{
html = sr.ReadToEnd();
}
const string MatchPhondePattern = @"^\d{5}(?:[-\s]\d{4})?$";
Regex rx = new Regex(MatchPhondePattern, RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
MatchCollection matches = rx.Matches(html);
// Report the number of matches found.
int noOfMatches = matches.Count;
//Do something with the matches
foreach (Match match in matches)
{
//Do something with the matches
string tempPhoneNumber = match.Value.ToString(); ;
}
}
谁能帮我解决这个问题
【问题讨论】: