Ron
2006-12-31 17:47:54
Function code:
Test function code:
~Ron
// check to see if a certain string starts AND ends with something.
// returns true if the above is true.
// Made by Ron :)
function StartEnd(Str, StartsWith, EndsWith: string): boolean;
begin
if (lowercase(copy(Str, 1, Length(StartsWith))) = lowercase(StartsWith)) and (lowercase(copy(Str, Length(Str) - Length(EndsWith) + 1, Length(Str))) = lowercase(EndsWith)) then
begin
Result := True;
end else
begin
Result := False;
end;
end;
Test function code:
program New;
const
Website = 'http://www.google.com';
// check to see if a certain string starts AND ends with something.
// returns true if the above is true.
// Made by Ron :)
function StartEnd(Str, StartsWith, EndsWith: string): boolean;
begin
if (lowercase(copy(Str, 1, Length(StartsWith))) = lowercase(StartsWith)) and (lowercase(copy(Str, Length(Str) - Length(EndsWith) + 1, Length(Str))) = lowercase(EndsWith)) then
begin
Result := True;
end else
begin
Result := False;
end;
end;
begin
ClearDebug;
if(StartEnd(Website,'http://','.com'))then
WriteLn('"'+Website+'" starts with http:// and ends with .com');
end.
~Ron