diff options
author | Erich Eckner <git@eckner.net> | 2017-12-20 12:01:46 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-12-20 12:01:46 +0100 |
commit | 2fb1e0b965e8ab4563dcbf9e59b020f72cc66f84 (patch) | |
tree | c065a4420bb6161744d2bf963bad44e2b0616ea9 /tools.pas | |
parent | 177219f65a19cd16bf6222bd43a459c849df929f (diff) | |
download | Make-2fb1e0b965e8ab4563dcbf9e59b020f72cc66f84.tar.xz |
besseres und saubereres regex-handling
Diffstat (limited to 'tools.pas')
-rw-r--r-- | tools.pas | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -9,6 +9,7 @@ uses type tAktualitaet = (aNichtVorhanden,aVeraltet,aAktuell,aWirdErneuert); + tRegexTyp = (rtKein,rtFpc,rtShell); tMyStringListBArray = array[boolean] of tMyStringList; tSummenDatei = record name: string; @@ -43,6 +44,7 @@ procedure testeObBefehlLokal(bef, ordner: string; dateiListe: tMyStringList; lok function extrahiereAlleDateien(woraus: string; dateiListe: tMyStringList): tMyStringList; function unescape(s: string): string; function escape(s,toe: string; ec: char): string; +function escapeStringToRegex(s: string; typ: tRegexTyp; extras: string = ''): string; inline; procedure ersetzeAlleVorkommen(var worin: string; was,wodurch: string); // Routinen für sha512-Prüfsummen @@ -363,6 +365,18 @@ begin end; end; +function escapeStringToRegex(s: string; typ: tRegexTyp; extras: string = ''): string; +begin + case typ of + rtKein: + result:=s; + rtFpc: + result:=escape(s,'\.[+^$'+extras,'\'); + rtShell: + result:=escape(s,'\.[^$'+extras,'\'); + end{of case}; +end; + procedure ersetzeAlleVorkommen(var worin: string; was,wodurch: string); begin while pos(was,worin)>0 do begin |