I need the fastest find and replace ever made.

I need the fastest find and replace ever made. Maybe not really the fastest, but i just want to find and replace the right way.
For example string is a text of length of 30. i have a list of words that I want to find in the string and replace them with 'xyz'.

Do you have any idea what the best way is to load the list of words and then do the replacing?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

One way to do it is

  Str := StringReplace(Str,Key,'xyz',[rfReplaceAll]);

You can do the same as above but much faster using FastReplace from http://www.droopyeyes.com/default.asp?mode=ShowProduct&ID=4

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
or get madshi's components, and do a


// assuming that your keyword list is already in a TStringList called Keywords

for i := 0 to Keywords.Count - 1 do
  ReplaceStr(Str, Keywords[i], 'xyz', True);

from Madshi's help file:

The following functions search through the whole "str" and replace the fragment "replaceThis" every time it occurs "withThis". The replacement can be done recursively, if you wish. That means, that the replaced string fragments are checked again. "ReplaceStr" searches case sensitively, while "ReplaceText" searches case insensitively.

function ReplaceStr  (var str     : string;
                      replaceThis : string;
                      withThis    : string;
                      replaceSelf : boolean = false) : boolean;
function ReplaceText (var str     : string;
                      replaceThis : string;
                      withThis    : string;
                      replaceSelf : boolean = false) : boolean;

Get his package from www.madshi.net
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

AngeloXAuthor Commented:
Thnx I guess FastStrings will do. But do you also have any idea what the best way is to load a list of words and then go by them one for one? Is the fastest way to load them in a TList and then do a for loop for every word, or is there a faster way to do that?

Maybe You can find it usefull for stringreplace
AngeloXAuthor Commented:
That one was fast enough hehe. Thnx!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.