Introduction to several common javascript string processing functions:
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", and "PNG"
Function: John ()
Function: combines an array into a string using the separator you selected.
Example:
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.
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