求助:关于文件中提取邮件的算法
关于文件中提取邮件老鸟门能不能给个思路或者算法,小弟谢谢了
void CEAPDlg::BrowseDir(CString strDir)
{
CString flagstr(" \"<>\r\n[]{}:;=,'?#!`^$*%()");
int bufsize = m_list.GetCount();
CString *Word = new CString [bufsize];
for(int i=0;i<bufsize;i++)
{
m_list.GetText(i,Word[i]);
}
CFileFind finder;
CString szDir = strDir;
if(szDir.Right(1) != "\\")
szDir += "\\";
szDir += "*.*";
BOOL res = finder.FindFile(szDir);
while( res )
{
res = finder.FindNextFile();
if(finder.IsDirectory() && !finder.IsDots())
{
CString strPath = finder.GetFilePath();
CString strFileName = finder.GetFileName();
BrowseDir( strPath );
}
else if(!finder.IsDirectory() && !finder.IsDots())
{
CString strFileName = finder.GetFileName();
CString strFilePathName = finder.GetFilePath();
CString name = strFileName.Right(4);
if((name.Find(".eml") != -1) ||
(name.Find(".txt") != -1) ||
(name.Find(".dbx") != -1) )
{
CFile file;
if(!file.Open(strFilePathName,CFile::modeRead)) continue;
CString fstring = "";
char *readbuf ;
readbuf = fstring.GetBuffer(file.GetLength());
file.Read(readbuf ,file.GetLength());
file.Close();
fstring = readbuf;
CString s1 = "",s2 = "",s3 = "",s4 = "";
int pos1=0,pos2=0,pos3=0,pos4=0;
while((pos1 = fstring.Find("@")) != -1)
{
s1 = fstring.Left(pos1);
fstring.Delete(0,pos1+1);
s1.MakeReverse();
if((pos2=s1.FindOneOf(flagstr)) != -1)
{
s2 = s1.Left(pos2);
s2.MakeReverse();
}
if((pos3=fstring.FindOneOf(flagstr)) != -1)
{
s3 = fstring.Left(pos3);
}
if(s2!="" && (s3.Find(".")!=-1))
{
s4 = s2 + "@" + s3;
m_list.AddString(s4);
}
}
}
}
}
finder.Close();
delete []Word;
}
这有个算法,老鸟门怎么不出来帮忙哦,我想知道正则表达式要怎么写呀,帮帮忙呀