请教:怎样获取某段字符中,还有某个字符的数量?如"a|b|c|d|e|f"中还有5个“|”

ltq2001932 2006-01-17 11:26:19
请教:怎样获取某段字符中,还有某个字符的数量?如"a|b|c|d|e|f"中还有5个“|”
...全文
132 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hannibal7188616 2006-01-17
  • 打赏
  • 举报
回复
FUNCTION StrSum(LongStr,ShorStr) 'LongStr为要进行搜索的字符串,ShorStr为要统计的字符串
StrSum = 0 'StrSum存储要统计的字符串出现次数,初值为0
for i = 1 to len(LongStr)
Str = mid(LongStr,i,1) '遍历LongStr
if Str = ShorStr then '如果出现ShorStr,StrSum的值+1
StrSum = StrSum + 1
end if
next
END FUNCTION

'例
a = StrSum("a/b/c/d/e/f","/")
Response.Write a 'a等于5
KimSoft 2006-01-17
  • 打赏
  • 举报
回复
str = "a|b|c|d|e|f"

count = ubount(split(str, "|"))

response.write count
ltq2001932 2006-01-17
  • 打赏
  • 举报
回复
最好能举例看下,是用ASP的
ltq2001932 2006-01-17
  • 打赏
  • 举报
回复
打错字了。请教:怎样获取某段字符中,含有某个字符的数量?如"a|b|c|d|e|f"中含有5个“|”


KimSoft 2006-01-17
  • 打赏
  • 举报
回复
str = "a|b|c|d|e|f"

count = ubound(split(str, "|"))

MsgBox count

ubount应为ubound 写错了.

28,390

社区成员

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

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