Solved

StringReplace - How  replace all ocurrences?

Posted on 2001-09-14
3
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 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