diff options
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; |