RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
WideStrUtils.WideStringReplace Function

Replaces occurrences of a substring within a string.

Pascal
function WideStringReplace(const S: Widestring; const OldPattern: Widestring; const NewPattern: Widestring; Flags: TReplaceFlags): Widestring;
C++
BSTR WideStringReplace(const BSTR S, const BSTR OldPattern, const BSTR NewPattern, TReplaceFlags Flags);

WideStringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern in the string S.  

Flags is a TReplaceFlags type parameter. If rfIgnoreCase is set, the replacement is case-sensitive; otherwise case is ignored. If rfReplaceAll is on, all occurrences of OldPattern are replaced; if not, only the first occurrence is replaced.

Note: The parameters S, OldPattern, NewPattern, and the return value are of type WideString. To do the replacement in a UnicodeString context, use the StringReplace function. Also, to do the replacement in an AnsiString context, use the StringReplace function.
Note: Recursive replacement of substrings is not supported. This means that if the substitution of OldPattern results in a new match for NewPattern, that match is not replaced.
To replace all occurrences of the substring within the string, you may also use the WideReplaceStr function to do a case-sensitive search, or WideReplaceText to do a case-insensitive search. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!