delphi 根据邮箱地址分离出@前的内容


function PosCh(ch: Char; const S: String): Integer;
var
  I: Integer;
begin
  for I:=1 to Length(S) do
    if S[I] = ch then
    begin
      result := I;
      Exit;
    end;
  result := 0;
end;

function ExtractOwner(const S: String): String;
var
  P: Integer;
begin
  result := '';
  P := PosCh('@', S);
  if P > 0 then
    result := Copy(S, 1, P - 1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
showmessage(ExtractOwner('abc123@163.com'));
end;

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678