比如有一段文本如下:1 回复:我来留下
[email protected]
谢谢
----------
2 回复:我也留下
[email protected]
----------
3 回复:非常好
[email protected]
---------- 现在我只要其中的邮箱部分,其它文字一律删除,最后成这样: [email protected]
[email protected]
[email protected] 希望可以给出代码,最好可以给我源码。谢谢。
[email protected]
谢谢
----------
2 回复:我也留下
[email protected]
----------
3 回复:非常好
[email protected]
---------- 现在我只要其中的邮箱部分,其它文字一律删除,最后成这样: [email protected]
[email protected]
[email protected] 希望可以给出代码,最好可以给我源码。谢谢。
如果两邮箱挨着,那就没办法分出来,比如'[email protected][email protected]'Var
RowStr:String;
.... RowStr:='按时打发受到 [email protected] [email protected] ';
While Pos('@',RowStr)>0 do
begin
if Pos(' ',RowStr)>0 then
begin
if Pos(' ',RowStr)>Pos('@',RowStr) then
Memo1.Lines.Add(Copy(RowStr,1,Pos(' ',RowStr)-1));
RowStr:=Copy(RowStr,Pos(' ',RowStr)+1,length(RowStr));
end
else
begin
Memo1.Lines.Add(RowStr);
RowStr:='';
end;
end;
var
i,iPos:integer;f:TextFile;s:String;
begin
Result := '';
AssignFile(f,'c:\a.txt');
Reset(f);
while not eof(f) do
begin
ReadLn(f,s);
iPos := Pos('@',s);
if (iPos > 0) and (PosEx('.',s,iPos+1) > 0) then
begin
if Result = '' then
Result := s
else
Result := Result + #13#10 + s;
end;
end;
CloseFile(f);
end;大致就是这样,或许有几个地方编译不通过,莫怪。手打的。
那如果邮箱后面还有数字或者文字呢
比如:
"[email protected] 你好啊,怎么办"
上面这个情况貌似会出现,