首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请问怎么去字符串中引号的值啊

2012-02-11 
请教如何去字符串中引号的值啊!?请教如何去字符串中引号的值啊!?如bordervalue 北京合肥市 borderborde

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

[解决办法]
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
[解决办法]
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;

热点排行