假设此字符串:
uses Windows, Messages, SysUtils, {-} uCustom1, uCustom2, uCustom3;
{-}
之后如何在不知道固定长度的情况下全部捕获到左侧删除?可能RightStr
会有所帮助,但这需要较长的第二个参数,而我不知道该如何自动获取(在这种情况下,直到RightStr
都是这样)。有想法吗?
我通常使用此功能:
{-}
[function TailOf(const Input, Delimiter : String) : String;
var
P : Integer;
begin
P := Pos(Delimiter, Input);
if P > 0 then
Result := Copy(Input, P + Length(Delimiter), MaxInt)
else
Result := '';
end;
var
S : String;
S := 'ab{cd}def';
S := TailOf(S, '{cd}');
// S now = 'def'
和Pos
是标准的RTL函数,您可以在OLH中查找。
[我还有一个互补函数Copy
,它返回直到但不包括定界符的字符串的内容;如果找不到定界符,则返回整个字符串的内容。