Search for words MEMO!

5

I have a MEMO COMPONENT and there are several phrases in each line.

I need to search for words from this MEMO, for example: "BOLINHA". So far so good. The problem is, once it finds the word, I need it SAVE the LINE ALL that found the word.

Example:

"I HAVE A GUDE COOKIE".

He looks for the word BOLINHA in this sentence, if he finds it, he saves this whole PHRASE in another MEMO. Just this, can you help me?

    
asked by anonymous 08.03.2018 / 14:20

1 answer

3

For this you should go through the TMemo line by line and test if there is a occurrence of the word.

I think of something like:

  for i := 0 to Pred(Memo1.Lines.Count) do
  begin
    if (Memo1.Lines.Strings[i].Contains('BOLINHA') = True) then
      ShowMessage(Memo1.Lines.Strings[i]); //Faça o que quiser com essa linha
  end;

Overall this is, Memo1.Lines.Strings[i] is the line where the "First" occurrence of the word was found!

    
08.03.2018 / 15:42