JScript方法-lastIndexOf方法

来源:互联网 发布:mac文件夹删除快捷键 编辑:程序博客网 时间:2024/05/02 18:09
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
返回 string 对象中子字符串最后出现的位置。

strobj.lastindexof(substring[, startindex])

参数
strobj

必选项。string 对象或文字。

substring

必选项。要在 string 对象内查找的子字符串。

startindex

可选项。该整数值指出在 string 对象内进行查找的开始索引位置。如果省略,则查找从字符串的末尾开始。

说明
lastindexof 方法返回一个整数值,指出 string 对象内子字符串的开始位置。如果没有找到子字符串,则返回 -1。

如果 startindex 是负数,则 startindex 被当作零。如果它比最大字符位置索引还大,则它被当作最大的可能索引。

从右向左执行查找。否则,该方法和 indexof 相同。

下面的示例说明了 lastindexof 方法的用法:

function lastindexdemo(str2)
{
var str1 = "babebibobubabebibobu"
var s = str1.lastindexof(str2);
return(s);
}
要求
版本 1

<<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>