请教如何去字符串中引号的值啊!?如
border value="北京合肥市" border border如何取'北京合肥市"揭贴马上给分!如果一个字符串中有N个VALUE,怎么取呢?能把VALUE后面的值取出?

解决方案 »

  1.   

    var
      s:Widestring;
      posIndex:Integer;
      StrList:TStringList;
    begin
      StrList:= TStringList.Create;
      s:='border value="北京合肥市" border borderborder value="北京合肥市1" border borderborder value="北京合肥市2" border border?';
      posIndex:=pos( 'value',s );
      while posIndex > 0 do
      begin
        s:=copy( s,posIndex+7,length(s) );
        PosIndex:=pos( '"',s );
        if PosIndex > 0 then
          StrList.Add( copy( s,0,PosIndex-1 ) );    s:=Copy( s,PosIndex+1,length( s ) );
        posIndex:=Pos( 'value', s );
      end;
      self.ListBox1.Items.Assign( strList );
    end;
    --listbox显示结果
    北京合肥市
    北京合肥市1
    北京合肥市2
      

  2.   

    var
      ALst: TStringList;
      ASource: String;
      I: Integer;
    begin
      ALst := TStringList.Create;
      try
        ASource := '';    for I := 0 to 5 do
          ASource := ASource + '"北京合肥市'+InttoStr(I)+'"';    ALst.Delimiter := '"';
        ALst.DelimitedText := ASource;
        ASource := ALst.Text;
        ALst.Delimiter := '"';
        ALst.DelimitedText := ASource;    for I := 0 to 4 do
          ShowMessage(ALst.Strings[I]);
      finally
        FreeAndNil(ALst);
      end;
    end;