@Fahmy,
I enjoyed reading your code and decided to do similar steps using regular expressions. You might want to try it. Replace your ParseText with this one:
uses
.., regexpr;
function ParseText(const FLabel, FValue: TStrings; const Text, Format: string): boolean;
var
r: TRegExpr;
i: Integer;
K: String;
EscapedFormat: String;
begin
r := TRegExpr.Create;
//Extract labels from <SomeLabel>
r.Expression := '<([^>]+)>';
r.InputString := Format;
Result := r.Exec(1);
if Result then
begin
FLabel.Add(r.Match[1]);
while r.ExecNext do
FLabel.Add(r.Match[1]);
end
else
begin
r.Free;
Exit;
end;
//Escape RE chars used in Format
EscapedFormat := QuoteRegExprMetaChars(Format);
//Replace <> with (.+)
r.Expression:='(<[^>]+>)';
K := r.Replace(EscapedFormat, '(.+)', False);
EscapedFormat := K;
//Replace * with .+
r.Expression:='\\\*';
K := r.Replace(EscapedFormat, '.+', False);
//Apply it on Text
r.Expression := K;
r.InputString := Text;
Result := r.Exec(1);
if Result then
begin
for i := 1 to r.SubExprMatchCount do
FValue.Add(r.Match[i]);
end;
r.Free;
end;