diff options
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r-- | mystringlistunit.pas | 26 |
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; |