Interception of a digital string
1, using the parseInt ()
var str = "4500 membered";
var NUM = the parseInt (STR);
the console.log (NUM); // 4500
the parseInt () method parameter can have a non-numeric string, can be as long as the number before the string
2, using regular
var str = "price 4500 yuan";
var NUM = s.replace does (/ [^ 0-9] / IG, "");
Alert (NUM); // 4500
Interception string
1, using the split ()
Function: using the specified delimiter, cutting string, and stores the array var STR = "A, B, C, D, E, F";
var str.split ARR = ( ",");
the console.log (arr); // [ "a ", "b", "c", "d", "e", "f"]
2, using the join ()
Function: using their specified delimiter, will be merged into a string array
var ARR = [A, B, C, D, E, F];
var = arr.join STR ( "|");
the console.log (STR ); // "a | b | c | d | e | f"
3, using substring ()
Function: the specified field can be intercepted
var STR = "abcdef";
var str2 str.substring = (0,3);
the console.log (str2); // "ABCD"
4, using the indexOf ()
Function: Returns a string that matches the index of the first character of the substring
var STR = "Hello Web";
var str.indexOf S1 = ( "LL"); // 2
var str.indexOf S2 = ( "J "); // returns -1 if no match
5, using substr ()
Function: Returns a string length specified beginning from the specified location
var STR = "Hello Web";
var str.substr S1 = (0,4); // Hell
var str.substr S2 = (. 3); // "LO web "