This is an online collection of JS code snippet, used to determine whether the specified string is empty, filter the space on either side of a character in a string, find where the specified string starts, use the Isfloat function to determine whether a string consists of a number (int or long or float), The Isdigital function determines whether a string is composed of a number (int or long), and so on:
//The IsEmpty function determines whether a string is emptyfunctionIsEmpty (HIS) {flag=true; for(vari=0;i){if(His.charat (i)! = "") {flag=false; Break;}}returnFlag;}//trim function to remove spaces on both sides of a stringfunctionTrim (HIS) {//Find string start positionPos_start =-1; for(vari=0;i){if(His.charat (i)! = "") {Pos_start=i; Break; }}//Find string End positionPos_end =-1; for(vari=his.length-1;i>=0;i--){if(His.charat (i)! = "") {Pos_end=i; Break; }}//the returned stringStr_return = ""if(Pos_start!=-1 && Pos_end!=-1){ for(vari=pos_start;i<=pos_end;i++) {Str_return= Str_return +His.charat (i);}}returnStr_return;} //The Isdigital function determines whether a string consists of a number (int or long)functionisdigital (str) { for(ilen=0;ilen<str.length;ilen++){if(Str.charat (Ilen) < ' 0 ' | | str.charat (ilen) > ' 9 ' ){return false;} }return true;}//The Isfloat function determines whether a string consists of a number (int or long or float)functionisfloat (str) {Flag_dec= 0 for(ilen=0;ilen<str.length;ilen++){if(Str.charat (ilen) = = '. ') {Flag_dec++;if(Flag_dec > 1)return false;ElseContinue;} if(Str.charat (Ilen) < ' 0 ' | | str.charat (ilen) > ' 9 ' ){return false;} }return true;}
JS to determine whether the string is empty, filter the space, find the string position, and so on set of functions