From d7b4b3c06768e9839c0146d768415cb79b45384b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 25 Sep 2017 10:16:52 +0200 Subject: mystringlistunit.pas: tMyStringList.splitLines neu --- mystringlistunit.pas | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'mystringlistunit.pas') diff --git a/mystringlistunit.pas b/mystringlistunit.pas index 48bde05..381e5dc 100644 --- a/mystringlistunit.pas +++ b/mystringlistunit.pas @@ -39,6 +39,7 @@ type procedure insert(index: longint; const s: ansiString); override; function unfoldMacros(kvs: tKnownValues = nil; cbgv: tCallBackGetValue = nil): boolean; procedure subst(regex,ersatz: string); + procedure splitLines(before,after: string); procedure dump(pro: tProtokollant; prefix: string); procedure nichtInSubRoutine(s: string); procedure addWithLineBreaks(s: string); @@ -596,6 +597,31 @@ begin re.free; end; +procedure tMyStringList.splitLines(before,after: string); +var + i: longint; + s: string; +begin + i:=0; + while i'') and (pos(before,rightStr(self[i],length(self[i])-1))>1) do begin + insert(i,leftStr(self[i],1+pos(before,rightStr(self[i],length(self[i])-1))-1)); + inc(i); + self[i]:=rightStr(self[i],length(self[i])-length(self[i-1])); + end; + inc(i); + end; + i:=0; + while i'') and (pos(after,leftStr(self[i],length(self[i])-1))>1) do begin + insert(i,leftStr(self[i],pos(after,leftStr(self[i],length(self[i])-1))-1+length(after))); + inc(i); + self[i]:=rightStr(self[i],length(self[i])-length(self[i-1])); + end; + inc(i); + end; +end; + procedure tMyStringList.dump(pro: tProtokollant; prefix: string); var i: longint; -- cgit v1.2.3-70-g09d2