From 6127ae1152c7f7961b6fbfd80dc8c37db55e55c3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 20 May 2016 10:19:48 +0200 Subject: grep in mystrinlistunit.pas kann nun auch invertiert --- mystringlistunit.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mystringlistunit.pas') diff --git a/mystringlistunit.pas b/mystringlistunit.pas index af03f4a..31f9af5 100644 --- a/mystringlistunit.pas +++ b/mystringlistunit.pas @@ -25,7 +25,7 @@ type procedure saveToGz(const s: ansiString); function readln(out s: string): boolean; inline; function metaReadln(out s: string; subRoutine: boolean): boolean; inline; - procedure grep(expr: string); + procedure grep(expr: string; invert: boolean = false); function grepFirst(expr: string): string; function hatZeile(zeile: string): boolean; // invers zu "grep -c" function eof: boolean; @@ -185,7 +185,7 @@ begin result:=readln(s); end; -procedure tMyStringlist.grep(expr: string); +procedure tMyStringlist.grep(expr: string; invert: boolean); var re: tRegExpr; i: longint; @@ -193,7 +193,7 @@ begin re:=tRegExpr.create; re.expression:=expr; for i:=count-1 downto 0 do - if not re.exec(self[i]) then + if not invert xor re.exec(self[i]) then delete(i); re.free; end; -- cgit v1.2.3-70-g09d2