| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 | bar=new Array(0,'aa','abc',000,'',1,2,3,'',5,4,'fin de chaine p','',5,6,8)
Array.prototype.clean=function(reg){
temp= new Array().concat(this)
var i=-1;
while(temp[++i]!= undefined){reg.test('');
if( reg.test(temp[i].toString())){temp.splice(i--,1)}}
return temp
 }  
 
//eliminer les elements vides
bar1=bar.clean(/^$/)
alert ('array non vide\n'+bar1) 
 
//eliminer l'alpahbetique
bar2=bar.clean(/^\D*$/)
alert ('array numérique\n'+bar2) 
 
//eliminer le numerique
bar3=bar.clean(/^\d*$/)
alert ('array alpha\n'+bar3) 
 
 
//garder les elements commençant pas la lettre
bar4=bar.clean(/^$/).clean(/^[^a]/)
alert ('array debut a\n'+bar4) | 
Partager