如何在不知道固定长度的情况下删除字符串分隔符(包括分隔符)之前的所有内容?

How delete all content before a string delimiter (including the delimiter) without know a fixed lenght?

假设这个字符串:

uses Windows, Messages, SysUtils, {-} uCustom1, uCustom2, uCustom3;

如何在不知道要删除到左侧的固定长度的情况下捕获 {-} 之后的所有内容? 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'

PosCopy 是标准的 RTL 函数,您可以在 OLH 中查找。

我还有一个补充函数,HeadOf,它 returns 字符串的内容,但不包括分隔符,如果找不到分隔符,则为整个字符串。