1.10.12.15.17.20问题

sunlei_rxsoft 2008-12-16 08:44:36
我想把上面类型的字符串分开来,例如:1,10,12,15,17,20,怎么办,我有很多这样的字符串;
...全文
81 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rightyeah 2009-02-12
  • 打赏
  • 举报
回复
自己定义一个split函数,以后再也不愁了

global type split from function_object
end type

forward prototypes
global function integer split (string as_string, string as_separator, ref string as_array[])
end prototypes

global function integer split (string as_string, string as_separator, ref string as_array[]);string ls,sep
long i,lpos,p,ln
sep=as_separator
ls=as_string+sep

i=1
lpos=1
ln=len(sep)

p=pos(ls,sep,lpos)
do while p>0
as_array[i]=mid(ls,lpos,p - lpos)
lpos=p+ln
i++
p=pos(ls,sep,lpos)
loop
return i -1

end function

jjoulejcc 2008-12-19
  • 打赏
  • 举报
回复
是撒,有规律就能分
javaxi 2008-12-17
  • 打赏
  • 举报
回复
//大概也可以这样
//(none) uf_split(string as_str, ref string[] as_str_arr)
int i
i = upperbound(as_str_arr) + 1
if pos(as_str, ',') > 0
as_str_arr[upperbound(as_str_arr) + 1] = left(ls_str, pos(ls_str, ',') - 1 )
uf_split(mid( as_str, pos(as_str, ',') + 1 ), as_str_arr)
else
return
end if
liubocy 2008-12-16
  • 打赏
  • 举报
回复
string ls_str, ls_array[]
int i

ls_str = '1,10,12,15,17,20' + ','
do while pos(ls_str, ',') > 0
i ++
ls_array[i] = left(ls_str, pos(ls_str, ',') - 1 )
ls_str = mid( ls_str, pos(ls_str, ',') + 1 )
loop
eviler 2008-12-16
  • 打赏
  • 举报
回复
想分就分呗,但是你也要有个规则啊

743

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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