This article mainly introduces the JS string intercept function examples, the need for friends can refer to
Use the substring () or slice () function: Split () function: Use a specified delimiter to store a string into an array example: The code is as follows: Str= "Jpg|bmp|gif|ico|png"; Arr=thestring.split ("|"); Arr is an array function that contains the character values "JPG", "BMP", "GIF", "ico" and "PNG": John () function: Combine an array into a string example using the separator you choose: The 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 the Jpg|bmp|gif|ico|png function: substring () function: string interception, for example, to get "Minidx" from "minidxsearchengine" to use SUBSTRING (0,6) function: indexOf () function: Returns the subscript code for the first character of the matching substring in the string as follows: Var mystring= "JavaScript"; var w=mystring.indexof ("V"); W'll be 2 var x=mystring.indexof ("S"); x'll be is 4 var y=mystring.indexof ("Script"); Y would al So is 4 var z=mystring.indexof ("key"); Z'll be-1