summaryrefslogtreecommitdiff
path: root/mystringlistunit.pas
diff options
context:
space:
mode:
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r--mystringlistunit.pas30
1 files changed, 22 insertions, 8 deletions
diff --git a/mystringlistunit.pas b/mystringlistunit.pas
index fe6283c..47bc37c 100644
--- a/mystringlistunit.pas
+++ b/mystringlistunit.pas
@@ -24,8 +24,7 @@ type
line: longint;
prot: tProtokollant;
public
- constructor create; overload;
- constructor create(protokollant: tProtokollant); overload;
+ constructor create(protokollant: tProtokollant);
procedure loadFromFile(const s: ansiString); override;
procedure loadFromGz(const s: ansiString);
procedure saveToGz(const s: ansiString);
@@ -35,6 +34,7 @@ type
procedure rewind;
function stillNeed(bez: string): boolean;
function unfoldMacros: boolean;
+ procedure subst(regex,ersatz: string);
end;
procedure _del(var s: string; p,c: longint); inline; // identisch zu delete(s,p,c) -- lediglich um delete innerhalb von tMyStringlist verfügbar zu haben
@@ -77,11 +77,6 @@ end;
// tMyStringlist ***************************************************************
-constructor tMyStringlist.create;
-begin
- create(nil);
-end;
-
constructor tMyStringlist.create(protokollant: tProtokollant);
begin
inherited create;
@@ -278,7 +273,7 @@ begin
t:=erstesArgument(s,':');
if (length(t)=0) or (t[1]<>'$') then exit;
- SchleifenInhalt:=tMyStringlist.create; // Schleifenkörper merken
+ SchleifenInhalt:=tMyStringlist.create(nil); // Schleifenkörper merken
Ebene:=0;
while (i<Count) and ((Ebene<>0) or (self[i]<>'!Schleifenende')) do begin
SchleifenInhalt.Add(self[i]);
@@ -403,6 +398,25 @@ begin
result:=true;
end;
+procedure tMyStringlist.subst(regex,ersatz: string);
+var
+ i,cnt: longint;
+ re: tRegExpr;
+begin
+ re:=tRegExpr.create;
+ re.expression:='^(.*)('+regex+')(.*)$';
+ cnt:=3;
+ for i:=1 to length(regex) do
+ if (regex[i]='(') and
+ ((i=1) or (regex[i-1]<>'\')) then
+ inc(cnt);
+ for i:=0 to count-1 do begin
+ re.exec(self[i]);
+ self[i]:=re.substitute('$1'+ersatz+'$'+inttostr(cnt));
+ end;
+ re.free;
+end;
+
// allgemeine Funktionen *******************************************************
procedure _del(var s: string; p,c: longint);