1.
/* Review the operation of the string:
* Search--------Find, return the position of the character
* SUBSTRING-----Get substring, Parameters: Start point, end point (not included)
* CharAt--------Get a character
* Split---------Split string, return array */
functionFindNum () {varstr = ' FFF er344 233 ==-=fa80 '; vararr = []; vartemp = '; for(vari=0;i<str.length;i++){ if(Str.charat (i) >= ' 0 ' && str.charat (i) <= ' 9 ') {Temp+=Str.charat (i); }Else { if(temp) {Arr.push (temp); Temp= ";//Avoid repeating additions } } } if(temp) {Arr.push (temp); Temp= ' '; } console.log (arr);//Output [' n ', ' ['] ', ' 344 ', ' 233 ', ' + '}
2, the use of regular
function findnum_1 () { var str = ' FFF er344 233 ==-=fa80 '; Console.log (Str.match (/\d+/g)); var str1 = ' adsf csdvsdnkvl ';}
The functions of the two implementations are similar.
3.
I-----ignoring case
\d--------Numbers
G---------Global Match
js--Regular