本页内容
上一节: Func_instr 下一节: Func_lcase

VBScript InStrRev 函数

完整的 VBScript 参考手册

InStrRev 函数返回字符串在另一字符串中首次出现的位置。搜索从字符串的末端开始,但是返回的位置是从字符串的起点开始计数的。

InStrRev 函数可返回下面的值:

  • 如果 string1 为 "" - InStrRev 返回 0
  • 如果 string1 为 Null - InStrRev 返回 Null
  • 如果 string2 为 "" - InStrRev 返回 start
  • 如果 string2 为 Null - InStrRev 返回 Null
  • 如果 string2 没有找到 - InStrRev 返回 0
  • 如果在 string1 中找到 string2 - InStrRev 返回找到匹配字符串的位置
  • 如果 start > Len(string1) - InStrRev 返回 0

提示:请参阅 InStr 函数。

语法


InStrRev(string1,string2[,start[,compare]])

参数 描述
string1 必需。需要被搜索的字符串。
string2 必需。需要搜索的字符串表达式。
start 可选。规定每次搜索的起始位置。默认的搜索起始位置是最后一个字符(-1)。
compare

可选。规定要使用的字符串比较类型。默认是 0。 可采用下列的值:

  • 0 = vbBinaryCompare - 执行二进制比较
  • 1 = vbTextCompare - 执行文本比较

实例 1

示例

<script type="text/vbscript">

txt="This is a beautiful day!"

document.write(InStrRev(txt,"beautiful"))

</script>

以上实例输出结果:


示例

11

实例 2

查找字母 "i",采用不同的起始位置:


示例

<script type="text/vbscript">

txt="This is a beautiful day!"

document.write(InStrRev(txt,"i",-1) & "<br />")

document.write(InStrRev(txt,"i",7) & "<br />")

</script>

以上实例输出结果:


示例

16

6

实例 3

查找字母 "T",采用文本和二进制比较:


示例

<script type="text/vbscript">

txt="This is a beautiful day!"

document.write(InStrRev(txt,"T",-1,1) & "<br />")

document.write(InStrRev(txt,"T",-1,0) & "<br />")

</script>

以上实例输出结果:


示例

15

1

完整的 VBScript 参考手册

上一节: Func_instr 下一节: Func_lcase
此页面最后编辑于2022年8月17日 (星期三) 17:58。