在文本的特定位置插入空格:
例如:
张三 *123456789学生
李四无 *987654321干部
。要求:
在*之后第九个位置插入空格使文本文件如下:
张三 *123456789 学生
李四无 *987654321 干部
例如:
张三 *123456789学生
李四无 *987654321干部
。要求:
在*之后第九个位置插入空格使文本文件如下:
张三 *123456789 学生
李四无 *987654321 干部
procedure TForm1.Button1Click(Sender: TObject);
var
t:TStringList;
i,p:integer;
s:string;begin
t:=TStringList.Create;
t.LoadFromFile('d:\temp\t.txt');
for i:=0 to t.Count-1 do
begin
s:=t.Strings[i];
p:=pos('*',s);
t.Strings[i]:=copy(s,1,p+9)+' '+copy(s,p+10,MAXINT);
end;
t.SaveToFile('d:\temp\t1.txt');
t.Free;
end;