Solved

StringReplace - How  replace all ocurrences?

Posted on 2001-09-14
3
321 Views
Last Modified: 2010-04-06
Next code works fine one time but I don't know how (or where) must I include the parameter rfReplaceAll  to replace all occurrences.

procedure .....
var
 ..
 Flags: TReplaceFlags;
begin
 ..
 Memo1.Text := StringReplace(s, r1, r2, Flags);
 ..
end

Could anyone help me with the correct code?

Thanks.
0
Comment
Question by:boc7900
3 Comments
 
LVL 3

Accepted Solution

by:
raidos earned 100 total points
ID: 6482380
If you want to replace all occurances, you will have to use the rfReplaceAll flag yes..

Var
  Flags : TReplaceFlags;
Begin
  Flags := [rfReplaceAll];
  Memo1.Text := StringReplace(s, r1, r2, Flags);
End;

You might want to ignore the case of the oldpattern, in which case flags should be set like this :
  Flags := [rfReplaceAll, rfIgnoreCase];


//raidos
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6482394
Hi boc7900,

StringReplace(s, r1, r2, [rfReplaceAll]);
0
 
LVL 3

Expert Comment

by:cubud
ID: 6482523
If you are working on a huge string, StringReplace (even in Delphi 6) is horrendously slow.  Use FastStrings !

http://www.stuckindoors.com/delphi/faststrings
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now