Link to home
Start Free TrialLog in
Avatar of helyonprime96
helyonprime96

asked on

String function in delphi

Hello experts!
Please help me.

I have a list of websites.
I need to create a function that determinates what is the site extension (.ru or .com)

Plese help me.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of helyonprime96
helyonprime96

ASKER

thanks, it works
please help me, how i can see this text between
<td valign="top">
and </td>

thanks

try



procedure TForm3.Button1Click(Sender: TObject);
begin
  ShowMessage(GetTopLevelDomain('https://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/'));
end;

function GetTopLevelDomain(const AURL: string): string;
var
  Index: Integer;
  Temp: string;
begin
  Result := '';

  Temp := Trim(AURL);
  Index := Pos('//', AURL);
  if Index > 0 then
  begin
    Inc(Index, 2);
    Temp := Copy(Temp, Index, Length(Temp) - Index);
  end;

  Index := Pos('/', Temp);
  if Index > 0 then
    Temp := Copy(Temp, 1, Index-1);

  Index := Length(Temp);
  while (Index > 0) and (Temp[Index] <> '.') do
  begin
    Result := Temp[Index] + Result;
    Dec(Index);
  end;
end;

Open in new window

procedure TForm1.Button1Click(Sender: TObject);
var
  str:string;
begin
  str:=Memo1.Text;
  repeat
    delete(str,1,pos('<td valign="top">',str)+ length('<td valign="top">')-1);
    showmessage(trim(copy(str,1,pos('</td>',str)-1)));
  until pos('<td valign="top">',Str) <= 0;
end;

Open in new window


Now I lost some points ;-)
EE works this way: All new questions are always posted separately as long as they are not directly related to the original question (or answering them does not provide further clarification for it).