Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search for a string in RichEdit then copy whole line

Status
Not open for further replies.

Kahungunu

Technical User
Aug 10, 2002
4
NZ
Hi all

can anybody help?
How do I search for all instances of a string in a RichEdit containing 10000 records, using a FindDialog, then copy the whole line of each instance of the string into a new Richedit for display.

Thanks.

 
Hi

maybe you could use the following method instead of using a find dialog

var i:integer;
begin
for i:=0 to RichEdit1.Lines.count-1 do
if pos('yourstring',RichEdit1.lines)>0 then
RichEdit2.lines.add(RichEdit1.lines);
end;


one thing to note is that the search will be case sensitive
 
Thanks a lot for your reply, sorry for taking so long to get back.
Anyway I used your suggestion and ended up using the code below so that case sensitivity was nill. I am unable to set the find dialog to recognise case sensitive options but that is a minor gliche at the moment.
Thanks again for your help.

var
Line, Count :integer;
TextFound, StringValue, UpperStringValue :string;
begin

Line := 0;
Count := 0;

with RichEdit1 do
TextFound := UpperCase(FindDialog1.FindText);

While line < RichEdit1.Lines.Count do
Begin
StringValue := RichEdit1.Lines[Line];

inc (Line);

UpperStringValue := UpperCase (StringValue);

If Pos(TextFound, UpperStringValue) <> 0 then
Begin

Memo1.Lines.Add(StringValue);

inc (Count);
end;
end;
 
For your TFindDialog to recognise case sensitivity:

- make sure the frDisableMatchCase and frHideMatchCase properties of the TFindDialog are set to false

- you can add the following line to check if the 'Match Case' check box was checked by the user when the find dialog was shown:
Code:
if frMatchCase in FindDialog.Options then
{do some processing}

If you have any more questions about TFindDialog let me know Clive [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top