Показать сообщение отдельно
Старый 24.05.2010, 11:09   #7
Местный
 
Аватар для supernewbie
 
Регистрация: 23.09.2009
Сообщений: 1,232
Сказал Спасибо: 119
Имеет 172 спасибок в 134 сообщенях
supernewbie пока неопределено
По умолчанию

Цитата:
Сообщение от Xen Посмотреть сообщение
Код:
s:='Это тестовая строка для поиска слова';
i:= pos('строка',s); // pos -  регистрозависимая фун-я!

//---------------------------------------------

function LastPos(SearchStr, Str: string): Integer;
 var
    i: Integer;
   TempStr: string;
 begin
   Result := Pos(SearchStr, Str);
   if Result = 0 then Exit;
   if (Length(Str) > 0) and (Length(SearchStr) > 0) then
   begin
     for i := Length(Str) + Length(SearchStr) - 1 downto Result do
     begin
       TempStr := Copy(Str, i, Length(Str));
       if Pos(SearchStr, TempStr) > 0 then
       begin
         Result := i;
         break;
       end;
     end;
   end;
 end;

//---------------------------------------------

function NextPos(SearchStr, Str: string; Position: Integer): Integer;
 begin
   Delete(Str, 1, Position - 1);
   Result := Pos(SearchStr, upperCase(Str));
   if Result = 0 then Exit;
   if (Length(Str) > 0) and (Length(SearchStr) > 0) then
     Result := Result + Position + 1;
 end;

//---------------------------------------------

function NextPosRel(SearchStr, Str: string; Position: Integer): Integer;
 begin
   Delete(Str, 1, Position - 1);
   Result := Pos(SearchStr, UpperCase(Str)) - 1;
 end;

//---------------------------------------------

function ReplaceStr(Str, SearchStr, ReplaceStr: string): string;
 begin
   while Pos(SearchStr, Str) <> 0 do
   begin
     Insert(ReplaceStr, Str, Pos(SearchStr, Str));
     Delete(Str, Pos(SearchStr, Str), Length(SearchStr));
   end;
   Result := Str;
 end;
А еще"встроенные" AnsiStrRScan, AnsiPos т.д.
госпади, а можно хотя бы с пояснениями)
supernewbie вне форума   Ответить с цитированием