I have a function that breaks a string with a separator:
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;
Result := urlSplit[i].Substring(indexMet);
Exit;
end;
end;
end;
The function works great when the delimiter is the only character ('&', '|'). How to pass a newline character as a separator. I tried C # 13 # 10, '# 13 # 10', sLineBreak, Chr (13) + Chr (10), but they do not work.
source
share