Use substring () or slice ()
Function: split ()
Function: uses a specified separator to split a string and store it in an array.
Example:
Copy codeThe Code is as follows:
Str = "jpg | bmp | gif | ico | png ";
Arr = theString. split ("| ");
// Arr is an array containing character values "jpg", "bmp", "gif", "ico", and "png"
Function: John ()
Function: combines an array into a string using the separator you selected.
Example:
Copy codeThe Code is as follows:
Var delimitedString = myArray. join (delimiter );
Var myList = new Array ("jpg", "bmp", "gif", "ico", "png ");
Var portableList = myList. join ("| ");
// The result is jpg | bmp | gif | ico | png.
Function: substring ()
Function: String truncation. For example, substring () is used to obtain "Minidx" from "MinidxSearchEngine)
Function: indexOf ()
Function: returns the subscript of the first character matching the substring in a string.
Copy codeThe Code is as follows:
Var myString = "JavaScript ";
Var w = myString. indexOf ("v"); w will be 2
Var x = myString. indexOf ("S"); x will be 4
Var y = myString. indexOf ("Script"); y will also be 4
Var z = myString. indexOf ("key"); z will be-1