diff options
author | Erich Eckner <git@eckner.net> | 2019-04-01 15:44:59 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-04-01 15:46:15 +0200 |
commit | 788e7e42a53b52ff2ff4cb7674ed631233c004a0 (patch) | |
tree | 715db3f1537dfa487c5cac1fbc2553e9cb52c694 /mystringlistunit.pas | |
parent | 2f0783fd90c36dc3b4f0565fa581314eea7bee2f (diff) | |
download | units-788e7e42a53b52ff2ff4cb7674ed631233c004a0.tar.xz |
mystringlistunit.pas: tMyStringList.findeZeile() neu
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r-- | mystringlistunit.pas | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/mystringlistunit.pas b/mystringlistunit.pas index df900a0..80da220 100644 --- a/mystringlistunit.pas +++ b/mystringlistunit.pas @@ -30,7 +30,8 @@ type procedure replace(von,nach: string); procedure uniq(c: char); procedure append(sl: tMyStringList); overload; - function hatZeile(zeile: string; regex: boolean = true): boolean; // invers zu "grep -c" + function findeZeile(zeile: string; regex: boolean = true): longint; + function hatZeile(zeile: string; regex: boolean = true): boolean; inline; // invers zu "grep -c" function eof: boolean; procedure rewind; procedure stepBack; @@ -301,18 +302,19 @@ begin add(sl[i]); end; -function tMyStringList.hatZeile(zeile: string; regex: boolean = true): boolean; +function tMyStringList.findeZeile(zeile: string; regex: boolean = true): longint; var re: tRegExpr; i: longint; begin - result:=true; + result:=-1; 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; + result:=i; exit; end; end; @@ -320,9 +322,15 @@ begin end else for i:=0 to count-1 do - if self[i]=zeile then + if self[i]=zeile then begin + result:=i; exit; - result:=false; + end; +end; + +function tMyStringList.hatZeile(zeile: string; regex: boolean = true): boolean; +begin + result:=findeZeile(zeile,regex)>=0; end; function tMyStringList.eof: boolean; |