Instr()

Instr()

  编辑
本词条缺少 名片图,补充相关内容使词条更完整,还能快速升级,赶紧来 编辑吧!
Instr()函数返回字符或字符串在另一个字符串中第一次出现的位置.
中文名
Instr()
表达式
strToBeSearched, strSearchFor
性    质
函数
形    式
返回字符或字符串

目录

应用示范

编辑
Instr()
函数返回字符或字符串在另一个字符串中第一次出现的位置.
表达式 Instr([start, ] strToBeSearched, strSearchFor [, compare])
允许数据类型: Start为搜索的起始值,strToBeSearched接受搜索的 字符串 strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)
示范1:
<%
strText = "This is a test!!"
pos = Instr(strText, "a")
response.write pos
%>
返回结果: 9
备注:如果接受搜索的字符串中没有要搜索的字符串,则返回结果为0。
示范2:
<%
strText = "This is a test!!"
pos = Instr(strText, "b")
response.write pos
%>
返回结果: 0

应用实例

编辑
计算某一目标字符串在另一字符串中出现的次数
Function CountStrings(longstring, target)
Dim position, count
position = 1
Do While InStr( position, longstring, target)
position = InStr(position, longstring, target) + 1
count = count + 1
Loop
CountStrings = count '函数返回计算结果
End Function
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值