AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi how to use the option flag rfReplaceAll in ReplaceStr

how to use the option flag rfReplaceAll in ReplaceStr

Ein Thema von piedad · begonnen am 25. Jun 2020 · letzter Beitrag vom 25. Jun 2020
Antwort Antwort
piedad

Registriert seit: 5. Jun 2020
10 Beiträge
 
#1

how to use the option flag rfReplaceAll in ReplaceStr

  Alt 25. Jun 2020, 15:39
Hallo Guys,
I Need some help. I am trying something very simple: to build a function to calculate the email addresse from the first Name and last Name for a loop in a QDA Batch.
Since i am Living in Germany know, I am using the german Keyboard, so I have to replace my ä with ae, and so on.
Not a big deal. But trying to use the Option rfReplaceAll I am getting stucked.
I tried to define it as a type, as a set, Nothing is working with an Syntax Error. Could you give me a hint? I am sure it is because a Little type Definition and I am new in Delphi.:
Many thanks in Advance and best regards
Piedad

Here is my last code

// calculate the email adresse from the related PErson
function eMailAdresseCalculator(Person: String): string ;
type
TReplaceFlags = [rfReplaceAll, rfIgnoreCase];
var
FirstName : String;
LastName : String
joint : Index;
options : TReplaceFlags;

begin

joint := Pos(' ', Person);
FirstName:= LowerCase(Trim(LeftStr(Person,joint)));
LastName := LowerCase(Trim(RightStr(Person,(Length(Person)-joint))));
options := rfReplaceAll;

Result := FirstName + '.' + LastName +'@Firma.com';
Result := ReplaceStr(Result,'ä','ae',options);
Result := ReplaceStr(Result,'ö','oe',options);
Result := ReplaceStr(Result,'ü','ue',options);

end;
  Mit Zitat antworten Zitat
DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#2

AW: how to use the option flag rfReplaceAll in ReplaceStr

  Alt 25. Jun 2020, 15:40
Why do you re-declare TReplaceFlags ?

Delphi-Quellcode:
options := [rfReplaceAll];
ReplaceStr(Result,'ä','ae',options);
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#3

AW: how to use the option flag rfReplaceAll in ReplaceStr

  Alt 25. Jun 2020, 15:52
By the way: You will probably want to substitute ß with ss as well
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.114 Beiträge
 
Delphi 12 Athens
 
#4

AW: how to use the option flag rfReplaceAll in ReplaceStr

  Alt 25. Jun 2020, 18:00
Declaring this type is not really right
and it's totally wrong how it was declared. (ENUM <> SET)


ReplaceStr does not have this parameter, because everything is always replaced there and the case sensitivity is controlled by the function name.

Delphi-Quellcode:
// System.StrUtils
S := ReplaceStr(S, Old, New); // same as StringReplace(S, Old, New, [rfReplaceAll])
S := ReplaceText(S, Old, New); // same as StringReplace(S, Old, New, [rfReplaceAll, rfIgnoreCase])

// System.SysUtils
S := StringReplace(S, Old, New, [rfReplaceAll]);

// System.SysUtils : TStringHelper
S := S.Replace(Old, New); // implicit rfReplaceAll
S := S.Replace(Old, New, [rfReplaceAll]);
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (25. Jun 2020 um 18:45 Uhr)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz