Ansi StringReplace Challenge

The objective is to build the fastest partiel replacement for RTL StringReplace.

AnsiStringReplace is a replacement for the RTL StringReplace function, but valid for AnsiStrings only.

function StringReplace(const S, OldPattern, NewPattern: AnsiString; Flags: TReplaceFlags): AnsiString;

StringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern.  S is the source string, whose substrings are changed. OldPattern is the substring to locate and replace with NewPattern. NewPattern is the substring to substitute for occurrences of OldPattern. Flags is a set of flags that govern how StringReplace locates and replaces occurrences of OldPattern. If Flags does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, StringReplace replaces all instances of OldPattern with NewPattern. If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.


It is not allowed to call any Fastcode functions not created by the function owner, except RTL functions.

Validation and Benchmark Tool:

Tables of results: (AnsiStringReplaceBenchmark201.xls)

Tables of results: (blind challenge part)