如何向一字符串中插入字符???
向字符串"<Input Type="text" name="text1" Value="" Size=20>"中插入字符串"abc"
使其变为:
         "<Input Type="text" name="text1" Value="abc" Size=20>"

解决方案 »

  1.   

    .... value="%S" ......Format(...)
      

  2.   

    str : string;str := 'pp' ;
    str := str[1]+'okk'+str[2] ;
    showmessage(str) ;
      

  3.   

    s:='<Input Type="text" name="text1" Value="" Size=20';if pos('Value="',s)>0 then
    begin
        s:=copy(s,1,pos('Value="',s)-1)+'abc'+copy(s,pos('Value="',s)+7,
        length(s)-pos('Value="',s)-6);
        showmessage('ok!');
    end;
      

  4.   

    有一个insert函数
    Delphi syntax:procedure Insert(Source: string; var S: string; Index: Integer);DescriptionIn Delphi code, Insert merges Source into S at the position S[index].Source is a string-type expression. S is a string-type variable of any length. Index is an integer-type expression. It is a character index and not a byte index.If Index is less than 1, it is mapped to a 1. If it is past the end of the string, it is set to the length of the string, turning the operation into an append.If the Source parameter is an empty string, Insert does nothing.Insert throws an EOutOfMemory exception if it is unable to allocate enough memory to accomodate the new returned string.
    例如:
    s:='abcde';
    insert('123',s,3);
    showmessage(s)
      

  5.   

    s:='<Input Type="text" name="text1" Value="" Size=20';
    Insert(s,'abc', Pos(s, 'Value="')) ;
      

  6.   

    不用插入了,直接替换好了
    s:='<Input Type="text" name="text1" Value="" Size=20>'
    replace(s,'value=""','value="aaa"')