Solved

StringReplace - How  replace all ocurrences?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 96
Delphi: how to implement a User Shortcut mapper? 1 119
How to renew a Delphi rad-studio licence? 5 69
SUM 2 INTEGER ARRAYS INTO 1 10 108
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

829 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