急盼:如何能把文本文件里的email地址提起出来?(100分)

  • 主题发起人 主题发起人 panzichan
  • 开始时间 开始时间
P

panzichan

Unregistered / Unconfirmed
GUEST, unregistred user!
急盼:如何能把文本文件里的email地址提起出来?
 
www.playicq.com里有关于这个的原代码.
好象是其他语言的,去看看吧.
 
用正则表达式,有这样一个控件的。你留下信箱我发给你
 
amourz:
我的邮箱是:panzichan@vip.sina.com
 
thank amourz Wrainbug
 
#include <stdio.h>
String GetEmail(String FileName)
{
FILE *in, *in1;
char readchar;
char readchar1;
String EMailAddr="";
String StrEMailAddr="";
if ((in = fopen(FileName.c_str(), "rb"))== NULL)
return "";
if ((in1 = fopen(FileName.c_str(), "rb"))== NULL)
return "";
fseek(in, 0L, SEEK_END);
int length= ftell(in);
fseek(in, 0L, SEEK_SET);
fseek(in1, 0L, SEEK_SET);
for( int i=0;i<length;i++)
{
fread(&amp;readchar,sizeof(readchar),1,in);
if(readchar=='@')
{
fseek(in1, i-1, SEEK_SET);
fread(&amp;readchar1,sizeof(readchar1),1,in1);
int j=2;
while((readchar1>='0'&amp;&amp;readchar1<='9')||(readchar1>='a'&amp;&amp;readchar1<='z')||(readchar1>='A'&amp;&amp;readchar1<='Z')||readchar1=='_'||readchar1=='.')
{
if((i-j)<=0)
break;
fseek(in1, i-j, SEEK_SET);
j++;
fread(&amp;readchar1,sizeof(readchar1),1,in1);
}
if(j>3)
{
fread(&amp;readchar1,sizeof(readchar1),1,in1);
while((readchar1>='0'&amp;&amp;readchar1<='9')||(readchar1>='a'&amp;&amp;readchar1<='z')||(readchar1>='A'&amp;&amp;readchar1<='Z')||readchar1=='_'||readchar1=='.'||readchar1=='@')
{

if((readchar1>='0'&amp;&amp;readchar1<='9')||(readchar1>='a'&amp;&amp;readchar1<='z')||(readchar1>='A'&amp;&amp;readchar1<='Z')||readchar1=='_'||readchar1=='.'||readchar1=='@')
EMailAddr+=AnsiString(readchar1);
fread(&amp;readchar1,sizeof(readchar1),1,in1);
}
if(EMailAddr.Length()>7&amp;&amp;EMailAddr[EMailAddr.Length()]!='@'&amp;&amp;EMailAddr[EMailAddr.Length()]!='.')
StrEMailAddr+=","+ EMailAddr;
EMailAddr="";
}
}

}
fclose(in);
fclose(in1);
return StrEMailAddr;

}

 
goddy:谢谢,如果你能把它换成DELHPI代码,我会比较容易看懂,我先送分啦
 
后退
顶部