Js|jscript returns the last occurrence of the substring of a string object.
Strobj.lastindexof (substring[, startindex])
Parameters
Strobj
Required option. A String object or text.
Substring
Required option. The substring to find within the string object.
startindex
Options available. The integer value indicates the starting index position of the lookup within the String object. If omitted, the lookup starts at the end of the string.
Description
The LastIndexOf method returns an integer value that indicates the starting position of the substring of the string object. If no substring is found, returns-1.
If the startindex is a negative number, the startindex is treated as zero. If it is larger than the maximum character position index, it is considered to be the largest possible index.
Performs a lookup from right to left. Otherwise, the method is the same as indexOf.
The following example illustrates the use of the LastIndexOf method:
function Lastindexdemo (STR2)
{
var str1 = "Babebibobubabebibobu"
var s = str1.lastindexof (STR2);
return (s);
}
Requirements
Version 1
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.