Code:
function GetSubStr(AInputStr, ABeginStr, AEndStr: String; AInclude: Boolean = False): String;
var
s: String;
sp, ep: Int64;
begin
Result := '';
if pos(ABeginStr, AInputStr) <> 0 then begin
sp := pos(ABeginStr, AInputStr) + length(ABeginStr);
s := copy(AInputStr, sp, length(AInputStr));
ep := pos(AEndStr, s) - 1;
Result := copy(s, 1, ep);
if AInclude then
Result := ABeginStr + Result + AEndStr;
end;
end;
Using:
Code:
var
Result: String;
begin
Result := GetSubStr('This my value <123> from string.', '<', '>');
// value of variable result = 123
end;