Avatar of Wayne Barron
Wayne Barron
Flag for United States of America

asked on 

Delete all text EXCEPT...

Hello All;

Button and Memo (That is all that is needed in this project)

OK.
Load the following into a Memo1



something here (12HG)
because we (4R5Y)
need it (6HY9)

I need to first
Loop through and delete all text that is not in the parentheses
Then after that
Loop through and delete all the parentheses ( & )
So that the only thing that is left is the items within the parentheses.

That should be a simple one, but I cannot seem to get the code that I have to work.
Supplied below.
Which I was trying to get to look at the ( and delete everything else.
Which will work if you put in    http://
But not    (

Thanks all
Carrzkiss
(I do not have to use this code provided, just should that I am trying myself as well)
procedure TForm1.Button1Click(Sender: TObject);
var Q:Integer;
begin
for Q :=Memo1.Lines.Count -1 downto 0 do
 begin 
if pos( '(', lowercase(Memo1.Lines[Q]) ) = 0 
   then Memo1.Lines.Delete(Q);
 end;
end;

Open in new window

Delphi

Avatar of undefined
Last Comment
Wayne Barron

8/22/2022 - Mon