Autor Beitrag
TimonWorld
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 10.01.04 20:56 
Hi ich möchte einem code editor mit sozusagen übersetzung von befehlen proggi! Mit nem klick auf dem Button soll er den Text: 'echo' durch 'Text: ' ersetzten und noch andere...

Aber wie?

Hier ein paar beispiele die ich in meinem editor erstzten will:
'COPY' -> 'Kopiere: '
'ECHO' -> 'Text: '
'RENAME' -> 'Umbennen:'
etc.

Aber, wie???

Moderiert von user profile iconPeter Lustig: Topic Verschoben
ixtreme
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 10.01.04 21:46 
Vielleicht ist ja StringReplace was für dich


Gruß

ixtreme.de
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 10.01.04 22:36 
und wie benutzt man den?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 10.01.04 22:45 
schonmal was von der Delphi-Hilfe gehört?? :P
Zitat:
StringReplace gibt einen String mit ersetzten Sub-Strings zurück.

Unit

SysUtils

Kategorie

String-Verarbeitung

type
TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;

Beschreibung

Mit StringReplace ersetzen Sie in dem angegebenen String den im Parameter OldPattern festgelegten Sub-String mit dem im Parameter NewPattern übergebenen neuen Sub-String. StringReplace nimmt an, daß der String Multibyte-Zeichen enthalten kann.

Wenn im Parameter Flags nicht rfReplaceAll enthalten ist, wird nur das erste Vorkommen von OldPattern im String S ersetzt. Andernfalls werden alle Instanzen von OldPattern durch NewPattern ersetzt.

Wenn der Parameter Flags rfIgnoreCase enthält, wird die Groß-/Kleinschreibung nicht berücksichtigt.

anwenden kann man das ganze so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var s:string;
begin
s:='dies ist ein text dies ist ein versuch "dies" soll nun durch "das" ersetzt werden';
s:=stringreplace(s,'dies','das',[rfReplaceAll,rfIgnoreCase]);
end;
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 10.01.04 22:49 
hilfe? was ist den das??? :lol:
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 10.01.04 22:57 
>> Aber wie soll ich den memo text in den string laden???
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 10.01.04 23:01 
z.B. zeilenweise...:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var i:Integer;
begin
for i:=0 to memo1.lines.count-1 do
begin
memo1.lines[i]:=stringreplace(memo1.lines[i],...);
end;
end;
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 11.01.04 16:27 
oda ganz:

Memo1.Text:=StringReplace(Memo1.Text, 'lebkuchen,'lab',[rfReplaceAll,rfIgnoreCase]);[/delphi]

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)