Substring.ReplaceLinguistic Method

Overload List

#SignatureDescription
1function ReplaceLinguistic(const OldPattern, NewPattern: string; const ReplaceFlags: TReplaceFlags): Substring; overload;Replaces OldPattern by NewPattern, found by the rules of the default locale or of LocaleID: the first occurrence, or every occurrence with rfReplaceAll; rfIgnoreCase ignores case.
2function ReplaceLinguistic(const OldPattern, NewPattern: string; const ReplaceFlags: TReplaceFlags; const LocaleID: TLocaleID): Substring; overload;

Overload 1: function ReplaceLinguistic(const OldPattern, NewPattern: string; const ReplaceFlags: TReplaceFlags): Substring; overload;

Replaces OldPattern by NewPattern, found by the rules of the default locale or of LocaleID: the first occurrence, or every occurrence with rfReplaceAll; rfIgnoreCase ignores case.

#NameTypeDescription
1OldPatternstring
2NewPatternstring
3ReplaceFlagsTReplaceFlags

Returns: Substring - The new value.

Remarks:

Every text kind for both patterns. A match may be longer or shorter than OldPattern; a pattern of only ignorable characters is never found. Note: This routine is 6.4 to 53 times slower than ReplaceAscii, and 6.7 to 85 times slower than Replace, due to handling of the locale specific char handling. Use ReplaceAscii or Replace, if this handling is not needed.

Examples

The soft hyphen inside the match is replaced with it.

uses Substr;

procedure Example;
begin
    Assert(Substring('ca'#$AD'f'#$E9).ReplaceLinguistic('caf'#$E9, 'tea', []) = 'tea');
end;
See Also: Substring.ReplaceAscii, Substring.ReplaceInvariant

Overload 2: function ReplaceLinguistic(const OldPattern, NewPattern: string; const ReplaceFlags: TReplaceFlags; const LocaleID: TLocaleID): Substring; overload;

#NameTypeDescription
1OldPatternstring
2NewPatternstring
3ReplaceFlagsTReplaceFlags
4LocaleIDTLocaleID

Returns: Substring