I' m having a function which splits a string by a delimiter:
function ExtractURL(url: string; pattern: string; delimiter: char): string;
var
indexMet, i: integer;
urlSplit: TArray<String>;
delimiterSet: array [0 .. 0] of char;
begin
delimiterSet[0] := delimiter;
urlSplit := url.Split(delimiterSet);
Result := '';
for i := 0 to Length(urlSplit) - 1 do
begin
if urlSplit[i].Contains(pattern) then
begin
indexMet := urlSplit[i].LastIndexOf('=') + 1; // extracts pairs key=value
Result := urlSplit[i].Substring(indexMet);
Exit;
end;
end;
end;
The function works fine when the delimiter is a single character ('&', '|'). How can I pass newline character as delimiter. I tried with #13#10, '#13#10', sLineBreak, Chr(13) + Chr(10) but they don't work.