一个字符串里包含了四个空格,怎样取第四个空格后的字符串
解决方案 »
- 關於使用 SQLDMO_TLB(sqldmo.dll) 列舉局域網內SQLServer的問題。
- 控件的试用期过后
- ehlib高手請進,回答完問題我給88分,絕對不食言
- 有关保存对话框TSaveDialog的问题
- ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
- SQLserver2000 查询速度为什么这么慢?
- 高难度动作:谁能给出把DOS窗口下交互式程序的标准输出通过管道放到标准的Windows控件中...
- IdSmtp 如何判断邮件是否发送成功?
- DELPHI ALT+F4总是出错
- 如何在一个query的查询中同时获得查到的记录数啊?
- 关于使用ado编程序,从oracle数据库到数据问题batchmove
- res文件丢失了,如何重新生成??
begin
if ThisStr[i]:=' ' then
begin
k:=K+1;
if K=4 then
begin
R:=i;
end;
end;
end;
TrimedStr:=copy(ThisStr,R,n);
str1:=RightStr(str,Legnth(str)-i+1)
i: integer;
p: integer;
str: string;
s: string;
begin
p := 0
i := 1;
repeat
if str[i]=' ' then
inc(p);
inc(i);
until p=4;
s := rightstr(str, length(str)-p);
end;
begin
index:=pos(' ',yourStr);
yourStr[index]:='';
end;StrYouWanted:=copy(yourStr,index,length(yourStr)-index);
怎样取第三个到第四个空格之间的字符串
var
i,k,m,n:integer;
str:string;
begin
str:=trim(listbox1.Items[0]);
for i:=1 to Length(str) do
begin
if str[i]=' ' then
begin
k:=K+1;
if K=6 then
begin
m:=i;
end;
if K=8 then
begin
n:=i;
end;
end;
end;
showmessage(copy(listbox1.Items[0],m,n-m));
为什么这样得到的是整个字符串
在最后加上以下代码这OK了
showmessage(inttostr(n));
var
i,k,m,n:integer;
str:string;
begin
k:=0;
str:=trim('123 4 5 6 7 89 999');
for i:=1 to Length(str) do
begin
if str[i]=' ' then
begin
k:=K+1;
if K=3 then m:=i;
if K=4 then n:=i;
end;
end;
showmessage(copy(str,m,n-m));
for i:=1 to 4 do
begin
index:=pos(' ',yourStr);
yourStr[index]:='';
if i=3 then
thirdSpace:=index;
if i=4 then
fourthSpace:=index;
end;StrYouWanted:=copy(yourStr,thirdSpace,fourthSpace-thirdSpace);