summaryrefslogtreecommitdiff
path: root/mystringlistunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-11-27 16:28:04 +0100
committerErich Eckner <git@eckner.net>2017-11-27 16:28:04 +0100
commitf17f1141bfc049e520cecd5437ec65e6b9bd1c3b (patch)
tree6dce1570b50ebb458a393e7edc65146623283c89 /mystringlistunit.pas
parentd34330a23cd6c556c61b15d2d0233a67afb002bd (diff)
downloadunits-f17f1141bfc049e520cecd5437ec65e6b9bd1c3b.tar.xz
mystringlistunit.pas: hatZeile kann nun auch Strings vergleichen
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r--mystringlistunit.pas26
1 files changed, 16 insertions, 10 deletions
diff --git a/mystringlistunit.pas b/mystringlistunit.pas
index 7aec8ee..e0b7fe2 100644
--- a/mystringlistunit.pas
+++ b/mystringlistunit.pas
@@ -30,7 +30,7 @@ type
procedure replace(von,nach: string);
procedure uniq(c: char);
procedure append(sl: tMyStringList); overload;
- function hatZeile(zeile: string): boolean; // invers zu "grep -c"
+ function hatZeile(zeile: string; regex: boolean = true): boolean; // invers zu "grep -c"
function eof: boolean;
procedure rewind;
procedure stepBack;
@@ -299,21 +299,27 @@ begin
add(sl[i]);
end;
-function tMyStringList.hatZeile(zeile: string): boolean;
+function tMyStringList.hatZeile(zeile: string; regex: boolean = true): boolean;
var
re: tRegExpr;
i: longint;
begin
- re:=tRegExpr.create;
result:=true;
- for i:=0 to count-1 do begin
- re.expression:=self[i];
- if re.exec(zeile) then begin
- re.free;
- exit;
+ if regex then begin
+ re:=tRegExpr.create;
+ for i:=0 to count-1 do begin
+ re.expression:=self[i];
+ if re.exec(zeile) then begin
+ re.free;
+ exit;
+ end;
end;
- end;
- re.free;
+ re.free;
+ end
+ else
+ for i:=0 to count-1 do
+ if self[i]=zeile then
+ exit;
result:=false;
end;