拆分汉字字符串

ooixx 2006-12-02 06:07:01
比如有一字符串
s:=‘真的好喜欢你’;
现在要把他分成
array f[0]:=‘真’;
f[1]:='的 ';
...........
f[5]:='你';
能写出详细的过程吗 有分的哦
...全文
121 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ooixx 2006-12-02
  • 打赏
  • 举报
回复
var
f,g:string;
i,j,k:integer;
begin
g:='喜欢你';
j:=length(g);
for i:=1 to j do
begin
if (i mod 2 <> 0 ) then
begin
f:=midstr(g,i,2);
showmessage(f);
//showmessage(inttostr(i));
end;
end;
end;

扼 我自己也想了一个出来 又学到了
哈哈 每人25分吧
lihuasoft 2006-12-02
  • 打赏
  • 举报
回复
var
str:string;
arr:array[0..6] of string;
I,J:integer;
begin
str:='我真的好喜欢你';
J:=1;
for I := 0 to 6 do
begin
arr[I]:=str[J]+str[J+1];
inc(J,2);
end;
for I:=0 to 6 do
//edit1.Text:=edit1.Text+arr[I];
end;
老冯 2006-12-02
  • 打赏
  • 举报
回复
var
Idx: Integer;
Str: String;
Arr: array of WideString;
Len: Integer;
begin
Len := 0;
Str := 'I我LOVE爱YOU你';
for Idx := 0 to Length(WideString(Str)) do
begin
if Ord(WideString(Str)[Idx]) >= $1000 then
begin
Inc(Len);
SetLength(Arr, Len);
Arr[Pred(Len)] := WideString(Str)[Idx];
end;
end;
end;

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧