[文字列を検索する]

文字列の中から、指定の文字列を探します。
【ソースコード】 [tips0019.pas]
program tips0019;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var
 strValue  :String;   // 文字列
 strFind   :String;   // 検索する文字列
 AnsiValue :AnsiString;   // 文字列
 AnsiFind  :AnsiString;   // 検索する文字列

begin
 strValue  := 'あいうえお';
 strFind   := 'い';

 AnsiValue := AnsiString(strValue);
 AnsiFind  := AnsiString(strFind);

 WriteLn('文字列「' + strValue + '」の「' + strFind + '」は');

 WriteLn(' ' + IntToStr(Pos(strFind, strValue))     + ' 文字目です。');
 WriteLn(' ' + IntToStr(Pos(AnsiFind, AnsiValue))     + ' バイト目です。');

 WriteLn(' ' + IntToStr(AnsiPos(strFind, strValue))   + ' 文字目です。');
 WriteLn(' ' + IntToStr(AnsiPos(AnsiFind, AnsiValue))   + ' 文字目です。');
 
end.
【コンパイル&実行】 [tips0019.bat]
dcc32 tips0019.pas 
tips0019.exe  > tips0019.txt
pause
【実行結果】 [tips0019.txt]
文字列「あいうえお」の「い」は
 2 文字目です。
 3 バイト目です。
 2 文字目です。
 2 文字目です。