一个字符串里包含了四个空格,怎样取第四个空格后的字符串
解决方案 »
- 求助如何将获得的短路径还原为长路径
- 关于服务程序里执行另一个可执行文件
- 喜欢上一个女孩子,散分。
- 毕业设计要用,急啊,高手来看一下
- 我需要写一个NT服务程序,需要连接数据库,采用多线程进行数据计算,那么请问,连接数据库写在什么地方?
- 救救我吧!谁能帮我解决问题。
- 用QuickReport 控件打印报表时,如何在程序中指定打印纸的长度?
- image + scrollbox如何设置,就是使大图有滚动条
- 请教:在SQL SERVER2000里面怎样让值显示为******?
- 很鸟的题目,最容易得分
- 关于使用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);