In Learning JS Foundation, sometimes learn to forget, write down to facilitate the next search and understanding:
The. Substring () method is used to extract the character of a string intermediary between two specified subscripts.
var str='abcdef'; alert (str.substring (25)); // starting from 2nd position (including 2 brothers) to 4th end (excluding 5th) pop-up CDE // Alert (str.substring (1)); // starting from 1th to last pop-up bcdef
The. CharAt () method returns the character at the specified position
var str='abcdef'; alert (Str.charat (0));//Output is a
The. Search () method is used to retrieve a substring specified in a string, or to retrieve a substring that matches a regular expression
var str='abcdef'; alert (Str.search ('b') )); // Output 1 position, 1alert (str.search ('u')); // location,-1
The. Split () method is used to split a string into a string array.
var str='12-56-aaa-89'; var arr=str.split ('-'// output 12,56,aaa,89
The. Replace () method is used to replace other characters with some characters in a string, or to replace a substring that matches a regular expression.
var str='ABC aaa ERW'; var re=/a/'0');//Replace all a with 0
The. Match () method retrieves the specified value within a string, or finds a match for one or more regular expressions.
var str='asdf 656 cvs33'; var re=/\d/G;alert (Str.match (re)); // Output 3,4,6,5,6,3,3 // var str= "Hello world!" // // World
The method used in JS