Search for words MEMO!

Asked

Viewed 802 times

4

I have a MEMO COMPONENT and within it there are several sentences on each line.

I need to search for words of this MEMO, example: "POLKA". So far so good. The problem is, after he finds the word, I need him to SAVE the WHOLE LINE that found the word.

Example:

"I HAVE A MARBLE".

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

1 answer

2

For this you must go through the TMemo line by line and testing if there is the 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;

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.