怎样判断字符串中有多少个a吗?

wwwpgcnnet 2005-01-08 09:39:03
有没有直接的命令?
...全文
370 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
minghui000 2005-01-09
  • 打赏
  • 举报
回复
up
超级大笨狼 2005-01-09
  • 打赏
  • 举报
回复
ubound(split(a,"a"))
fangq 2005-01-09
  • 打赏
  • 举报
回复
<script>
str=document.formName.textName.value;
for(i=0;i<str.length;i++)
{
if(str.substr(i,1)=="a") ++n;
}
</script>
n为字符"a"的个数!
超级大笨狼 2005-01-09
  • 打赏
  • 举报
回复
<SCRIPT LANGUAGE="vbScript">

Const a = "klalskjkflaaklsdjalklia"
alert ubound(split(a,"a"))

</SCRIPT>

最直接的了
wwwpgcnnet 2005-01-09
  • 打赏
  • 举报
回复
看来没有直接的命令
love040309 2005-01-09
  • 打赏
  • 举报
回复
<%
fountion strsum(str)
strsum=0
for i=1 to len(str)
if mid(str,i,1)="a" then
strsum=strsum+1
end if
next
end fountion
%>
crazysoul 2005-01-09
  • 打赏
  • 举报
回复
Fix(Ubound(Split(str1,str2))+0.4)
我经常用的
cnetnet 2005-01-09
  • 打赏
  • 举报
回复
最后的应该是len("dsfafdafasadf")-len(replace("dsfafdafasadf","a",""))才正确吧。。
如果是通过的,那ubound(split(a,"a"))是最好了。呵。。没测试过,在用二维数组的时候,我是用ubound的。
cnetnet 2005-01-09
  • 打赏
  • 举报
回复
最后的应该是len("dsfafdafasadf")-leg(replace("dsfafdafasadf","a",""))才正确吧。。
如果是通过的,那ubound(split(a,"a"))是最好了。呵。。没测试过,在用二维数组的时候,我是用ubound的。
yjb136 2005-01-09
  • 打赏
  • 举报
回复
len("dsfafdafasadf")-leg(replace("dsfafdafasadf"))

这样就是了
to_be_or_not_to_be 2005-01-08
  • 打赏
  • 举报
回复
Const a = "klalskjkflaaklsdjalklia"
Dim sPos: sPos = InStr(a, "a")
Dim x: x = 0
Do while sPos>0
x = x + 1
sPos = InStr(sPos+1, a, "a")
Loop
Response.Write x
tjficcbw 2005-01-08
  • 打赏
  • 举报
回复
<%
dim pconter
pconter=0
pstring="hjkhjkhahjkajahahahahahaklha"
for i=1 to len(pstring)
if mid(pstring,i,1)="a" then pconter=pconter+1
next
response.write pconter
%>
wztgq 2005-01-08
  • 打赏
  • 举报
回复
$string="hjkhjkhahjkajahahahahahaklha";
preg_match_all("#a#si",$string,$m);
echo count($m[0]);//输出a的个性,呵呵,PHP~
tjficcbw 2005-01-08
  • 打赏
  • 举报
回复
没有
conter=0 
string="hjkhjkhahjkajahahahahahaklha"
for i=1 to len(string)
if mid(string,i,1)="a" then conter=conter+1
next
response.write conter

28,391

社区成员

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

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