I have a TMemo with text inside it, for example:
Text1
Hello World!
Sky
Text123
I use a simple function to select the first time a text was found
Memo1.SelStart := Pos(AnsiLowerCase('Text'), AnsiLowerCase(Memo1.Text)) - 1;
Memo1.SelLength := Length('Text');
Memo1.SetFocus;
I used AnsiLowerCase so I can find text without the need for proper capitalization.
So, how can I select the second time "text" appears in the Memo?
You can use the
Offsetparameter of the Pos function in order to avoid starting search from the beginning and skip the first occurrence.For example: