Delete www string in delphi

hello experts.
please help me.

i have a list of sites.many sites contains www. in his link
i wrote a procedure that deletes it, but any times it doesnt work correctly.

There is :
function Deletewww(URL : string) : string;
begin
  if Pos('www.', URL) > 0 then Delete(Url, 1, 7);
  Result := Copy(Url, 1, Pos('w.', Url) - 1);
  if Result = '' then Result := URL;
end;

Please correct it.
Help me.
Thanks
helyonprime96Asked:
Who is Participating?
 
jimyXConnect With a Mentor Commented:
You can use "StringReplace" function to replace all the 'www.' with blanks:
function Deletewww(URL : string) : string;
begin
  Result := StringReplace(URL,'www.','',[rfReplaceAll, rfIgnoreCase]);
end;

Open in new window

0
 
helyonprime96Author Commented:
IT works !

Thanks a lot!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.