From f17f1141bfc049e520cecd5437ec65e6b9bd1c3b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 27 Nov 2017 16:28:04 +0100 Subject: mystringlistunit.pas: hatZeile kann nun auch Strings vergleichen --- mystringlistunit.pas | 26 ++++++++++++++++---------- 1 file 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; -- cgit v1.2.3-70-g09d2