1、在源字符串Src中查找子串S,返回Src中S之前的部分

Function Before( Src,S:string ): string ;
Var
  F: Word ;
begin
    if Src = '' then
      Before := '';
    F := Pos(S, Src);
  if F = 0 then
  begin
    Before := S;
  end
  else
    Before := Copy(Src,1,F-1);
end;

 

2、在源字符串Src中查找子串S,返回Src中S之后的部分

function After(Src: string; S: string):string;
Var
  F: Word ;
begin
  if Src = '' then After := '';
  F := Pos(S, Src);
  if F = 0 then
    After := ''
  else
    After := Copy(Src, F+Length(S), Length(Src));
end;

 

 

3、返回Src中 子串first与second之间的部分,找到立即返回

function Between(Src: string; first, second: string):string;
begin
  Between := Before(After(Src, first), second);
end;

相关文章:

  • 2022-12-23
  • 2021-12-12
  • 2021-11-18
  • 2021-10-27
  • 2021-10-09
  • 2022-03-06
  • 2022-01-12
  • 2022-02-27
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-12-27
  • 2021-12-12
相关资源
相似解决方案