1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<script type="text/javascript">
chaine = "rgb(175, 44, 44) rgb(153, 16, 16) rgb(37, 4, 4) rgb(180, 156, 156) ";
reg=/rgb\(([0-9 ]{1,3}),\s?([0-9 ]{1,3}),\s?([0-9 ]{1,3})\)/g;
colorsets=chaine.match(reg);
for (i=0;i<colorsets.length;i++){
foo=chaine.match('')
colorsets[i]= colorsets[i].replace(reg,'$1,$2,$3')
colorsets[i]=colorsets[i].split(',')
}
var res=""
for (i=0;i<colorsets.length;i++){
res+=' paramètres '+i+"\n";
res+='r ='+colorsets[i][0]+"\n";
res+='g ='+colorsets[i][1]+"\n";
res+='b ='+colorsets[i][2]+"\n\n";
}
alert (res)
</script> |
Partager