Solved

StringReplace - How  replace all ocurrences?

Posted on 2001-09-14
3
323 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 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