Sign in Join
Wiki copytemporary

StringReplace/de

StringReplace

Flags:

Flag Wert
rfReplaceAll 0
rfIgnoreCase 1

Syntax:

pascal
 Neuerstring := StringReplace(Originalstring,
                              String oder Zeichen das ersetzt werden soll,
                              String oder Zeichen, das stattdessen eingef??gt werden soll,
                              Ein Flag oder beide Flags in eckigen Klammern);

Anwendungsbeispiele

Beispiel 1

Entfernt alle Steuerzeichen aus einem String:

pascal
function funAlleSteuerzeichenEntfernen(strUebergabe: string): string;
var
  wrdI: word;

begin

  Result := strUebergabe;

  for wrdI := 0 to 31 do
    Result := StringReplace(Result, Chr(wrdI), '', [rfReplaceAll]);

end;

Beispiel 2

Entfernt alle Steuerzeichen außer dem Steuerzeichen Tab aus einem String:

pascal
function funAlleSteuerzeichenAusserTabEntfernen(strUebergabe: string): string;
var
  wrdI: word;

begin

  Result := strUebergabe;

  for wrdI := 0 to 31 do
  begin
    if wrdI = 9 then // filtert auf das Tabzeichen #9
      continue; // springt direkt zum Schleifenkopf
    Result := StringReplace(Result, Chr(wrdI), '', [rfReplaceAll]);
  end;

end;

Beispiel 3

Ignoriert Gross und Kleinschreiben in der Source.

pascal
var
  s: String;
begin
  ...
  s:= StringReplace(s, 'CbA', 'AbC', [rfReplaceAll, rfIgnoreCase]);

From the Free Pascal wiki, page "StringReplace/de", as it stood on 2020-04-08 after a change by Mathias, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.