> 文章列表 > string index out of range -7

string index out of range -7

string index out of range -7

关于string index out of range -7这个很多人还不知道,今天小六来为大家解答以上的问题,现在让我们一起来看看吧!

1、字符串越界 lastIndexOf 方法返回 String 对象中子字符串最后出现的位置

2、 strObj.lastIndexOf(substring[, startindex])lastIndexOf 方法返回一个整数值,指出 String 对象内子字符串的开始位置。

3、如果没有找到子字符串,则返回 -1。

4、 如果 startindex 是负数,则 startindex 被当作零。

5、如果它比最大字符位置索引还大,则它被当作最大的可能索引。

6、 从右向左执行查找。

7、否则,该方法和 indexOf 相同。

8、 下面的示例说明了 lastIndexOf 方法的用法: function lastIndexDemo(str2){ var str1 = \"BABEBIBOBUBABEBIBOBU\" var s = str1.lastIndexOf(str2); return(s);}。

本文到此分享完毕,希望对大家有所帮助。