请先登录 | 注册
MYCSG.CN
[ASP语法]Instr()返回字符首次出现的位置InstrRev() - 文章首页返回版区
■标题:[ASP语法]Instr()返回字符首次出现的位置InstrRev()
■作者:IPSC [2005/12/11 18:54:29]

Instr()
  FUNCTION: 返回字符或字符串在另一个字符串中第一次出现的位置.
  SYNTAX: Instr([start, strToBeSearched, strSearchFor , compare)
  ARGUMENTS: Start为搜索的起始值,strToBeSearched接受搜索的字符串 strSearchFor要搜索的字符compare 比较方式(详细见ASP常数)
  EXAMPLE: <%
  strText = "This is a test!!"
  pos = Instr(strText, "a")
  response.write pos
  %>
  RESULT: 9

        IPSC附言:BBSXP里经常用它来判断字段或者变量里是否包含指定的字符,如判断论坛一个版区的版主列表里是否包含现在访问的用户的名字
us123="yuzi|IPSC|daymoon"
if instr("|"&US123&"|","|"&"request.cookies("username")&"|")>0 then membercode=3

 

InstrRev()
  FUNCTION: 同上,只是从字符串的最后一个搜索起
  SYNTAX: InstrRev([start, strToBeSearched, strSearchFor , compare)
  ARGUMENTS: 同上.
  EXAMPLE: <%
  strText = "This is a test!!"
  pos = InstrRev(strText, "s")
  response.write pos
  %>
  RESULT: 13

[此帖子已被 IPSC 在 2005-12-12 8:17:50 编辑过]

回复/版区/上篇/下篇/发贴/仅文字/HTML

【倒序/最近21条回复】(暂无)
(查看完整版网页)



短讯|首页|登录|算法|电脑版 .
DK MiniBBS Plus v2.0
mm0759.com
109 毫秒 .