JS in the use of substr,substring,indexof,lastindexof,split, etc.1.substrSUBSTR (Start,length) is a string that starts at the start position and intercepts length lengths.var src= "Images/off_1.png";Alert (SRC.SUBSTR (7,3));The popup value is:
The following describes how to make the indexOf function in javascript case-insensitive.Replace all of them with uppercase or lowercase letters, and then compare them.This is a simple practice!The first occurrence of a substring In the indexOf
When testing IE8 today, the array does not support indexof. before using the indexof method, extend the array prototype method.
If (! Array. prototype. indexof) {array. prototype. indexof = function (ELT) {var Len = This. length >>> 0; var from =
The following describes how to make the indexof function in Javascript case-insensitive.
Replace all of them with uppercase or lowercase letters, and then compare them.
This is a simple practice!
The first occurrence of a substring In the indexof
Function: indexof ()
Function: returns the subscript of the first character matching the substring in a string.
CopyCode The Code is as follows: var mystring = "JavaScript ";
VaR W = mystring. indexof ("v"); W will be 2
VaR x = mystring.
Returns the first occurrence of a substring in a string object.
Strobj. indexof (substring [, startindex])
ParametersStrobj
Required. String object or text.
Substring
Required. The substring to be searched in the string object.
Starindex
Function: Split () Function: uses a specified separator to split a string and store it in an array.Example:STR = "JPG | BMP | GIF | ICO | PNG ";Arr = thestring. Split ("| ");// Arr is an array containing character values "jpg", "BMP", "GIF", "ICO",
One, definition and usageThe IndexOf () method returns the position of the first occurrence of a specified string value in a string.The LastIndexOf () method returns the location of the last occurrence of a specified string value, which is searched
int indexOf (int ch,int fromIndex) function: is the first position that the character Ch appears after the string FromIndex bit. No Rebates found-1Eg:string str= "A2DFCFAR1BZVB";System.out.println (Str.indexof (97,2));See this example, output: 6A's
IndexOf () method
indexOf() method returns the position of the first occurrence of a specified string value in a string.
Note: indexOf() methods are sensitive to case sensitivity!
Note: If the string value to retrieve does not appear, the method
Here's how to get the IndexOf function in JavaScript to ignore the case.
Change them all to uppercase or lowercase, and compare them.
This is a relatively simple approach!
IndexOf the character position of the substring for the first time within the
When you return a character in Java for the first time in the position of the string, string provides us with several valid APIs.
int indexOf (int ch)
//Returns the index at which the specified character appears for the first time in this
The IndexOf () method returns the location of the first occurrence of a specified string value in a string.
The LastIndexOf () method returns the last occurrence of a specified string value, which is searched forward at the specified position in a
IndexOf Method:
Returns the character position for the first occurrence of a substring within a string object.
Strobj.indexof (Substring[,startindex])
Parameters
Strobj
Required option. A string object or text.
SubString
Required option. The
JavaScript IndexOf method
The IndexOf method computes the first occurrence of a specified string in a string and returns that value. The syntax is as follows:
Copy Code code as follows:
Str_object.indexof (search, start)
This method is quite useful, many programming languages have a corresponding implementation, JavaScript is no exception, however, when I run the following code in IE:
Copy Code code as follows:
var arr = [1,2,3];
Alert (Arr.indexof
Ever want to find one of your JavaScript strings? Even start searching for half the string? Then you're in your good luck! The string function IndexOf allows you to provide an argument (search query), as well as an optional parameter (offset) to all
The Javascript string has an indexOf method that can return the position of a character in the specified string. This article describes how to add a similar method to the Javascript array.
// B =", B. join (","), ""); document. write (" B.
In JavaScript, the Array object does not have the indexOf () method. You can use the following code to expand it. If you need it, refer to the background: In the standard method of the Array object in JavaScript, there is no indexOf () method, the
Document directory
JavaScript indexOf () method
JavaScript substring () method
JavaScript split () method
JavaScript replace () method
JavaScript indexOf () method definition and usage
The indexOf () method returns the position of the first
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.