有一个E-mail地址:username@***.com,编一个程序,读出username.
1
{
------------------------------------------------------
}
2 { 从 ****@###.##中提取出**** }
3 { ------------------------------------------------------ }
4 function GetUserName(EmailAddress: string ): string ;
5 var
6 EdPosition : Integer;
7 begin
8 EdPosition : = AnsiPos( ' @ ' ,EmailAddress);
9 if EdPosition > 0 then
10 begin
11 result : = Copy(EmailAddress, 0 ,EdPosition - 1 );
12 end
13 else
14 Result : = EmailAddress;
15 end ;
16
2 { 从 ****@###.##中提取出**** }
3 { ------------------------------------------------------ }
4 function GetUserName(EmailAddress: string ): string ;
5 var
6 EdPosition : Integer;
7 begin
8 EdPosition : = AnsiPos( ' @ ' ,EmailAddress);
9 if EdPosition > 0 then
10 begin
11 result : = Copy(EmailAddress, 0 ,EdPosition - 1 );
12 end
13 else
14 Result : = EmailAddress;
15 end ;
16