diff options
author | Erich Eckner <git@eckner.net> | 2017-11-27 16:28:04 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-11-27 16:28:04 +0100 |
commit | f17f1141bfc049e520cecd5437ec65e6b9bd1c3b (patch) | |
tree | 6dce1570b50ebb458a393e7edc65146623283c89 /mystringlistunit.pas | |
parent | d34330a23cd6c556c61b15d2d0233a67afb002bd (diff) | |
download | units-f17f1141bfc049e520cecd5437ec65e6b9bd1c3b.tar.xz |
mystringlistunit.pas: hatZeile kann nun auch Strings vergleichen
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; |