替换字符串中的指定字符的问题

xpims 2005-09-29 10:01:30
str="aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,"

我想把字符串中第3个,第6个,第9个.....“逗号”替换成“分号”

有什么好的办法么?
...全文
103 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
itzhiren 2005-09-29
  • 打赏
  • 举报
回复
str="aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,"
dim s
s=""
arrStr = split(str,",")
for i=0 to ubound(arrStr)
if arrStr(i)<>"" then
if (i+1) mod 3=0 then
s = s & arrStr(i) & ";"
else
s = s & arrStr(i) & ","
end if
end if
next

response.write s
jzywh 2005-09-29
  • 打赏
  • 举报
回复
如果你的意思是

第3个,第6个,第9个 。。。。。

都是3的倍数的话

str="aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,"
dim result:result=""
arrStr = split(str,",")
for i=0 to ubound(arrStr)
if arrStr(i)<>"" then
if (i+1) mod 3 = 0 then
result = result & arrStr(i) & ":"
else
result = result & arrStr(i) & ","
end if
end if
next

response.write result
jzywh 2005-09-29
  • 打赏
  • 举报
回复
str="aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,"
dim result:result=""
arrStr = split(str,",")
for i=0 to ubound(arrStr)
if arrStr(i)<>"" then
if i=2 or i=5 or i=8 then
result = result & arrStr(i) & ":"
else
result = result & arrStr(i) & ","
end if
end if
next

response.write result
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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