Connection string
<ptml> <pead> <title> Connection string </title> </pead> <body> <script type= "Text/javascri PT "> var str1=" javascript string Connection "+", method one; var str2= "Method Two"; str2+= "Use + + connection"; var str3= "method three"; str3+= ", multiple string concatenation" + ". Use multiple characters simultaneously to connect" + ", correct! "; var str4= "string concatenation"; Str4=str4.concat ("Use concat function Connec string"); Window.alert (STR1); Window.alert (STR2); Window.alert (STR3); Window.alert (STR4); </script> </body> <ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Search string
Find the position of a string
Str.indexof (SUBSTR)
STR represents the specified string substr the substring to search for
Find the specified position character
Using Str.charat (n) str to represent the string n to be searched represents the position of the data type as the integral type represents the ordinal
var str1= "Jsstr"; Window.alert (Str1.charat (3));
Determines the last position in a string that appears
var n=str.lastindexof (ARGSTR);
Instance
<ptml> <pead> <title> string search </title> </pead> <body> <script type= "Text/javascri PT "> var str1=" Jsstr "; Alert (Str1.lastindexof ("S")); Alert (Str1.lastindexof ("str")); Alert (Str1.indexof ("S")); Alert (Str1.indexof ("Str")); </script> </body> <ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Splits a string into groups
var arry=str.split (s);
Where the parameter s is a separator or a split string
function split () use method
var str1= "Tom";
str1+= ", JERRY,JHON,SQM,QQQQ";
var strarry=new arry ();
Strarry=str1.split (",");
for (Var i=0;i<strary.length;i++)
{
Window.alert (Strary[i]);
}
Intercepts a string of strings
var str2=str1.substring (Begin[,end]);
Intercepting a part of a string this method is similar to a string function that intercepts the strings.
var str2=str1.slice (Begin,[,end]);
STR1 represents the truncated string str2 the truncated string argument bengin from which one to start intercepting the end parameter optionally, if you do not select the ending argument, it is truncated to the ends of the string