7 e mezzo Resizing Image (Ridimensionare immagini da PHP)
Aug 20

Funzione classica di tokenizzazione di stringhe

/Codice
 
//Funzione per la creazione di un array degli indici dei separatori
 
function setIndexes(phrase:String, sep:String) {
 for (i=0; i
 
  index = (phrase.indexOf(sep, i));
  if (index != index_arr[index_arr.length-1]) {
   index_arr.push(index);
  }
 }
 return (index_arr);
}
stringTokenizer = function (phrase:String, sep:String) {
 index = 0;
 if (sep.length>0) {
  index_arr = new Array("0");
 } else {
  index_arr = new Array();
 }
 var indexNames_arr:Array = new Array();
 setIndexes(phrase, sep);
 for (i=0; i
  if (i == 0) {
   indexNames_arr.push(phrase.slice(index_arr[i], index_arr[i+1]));
  } else {
   indexNames_arr.push(phrase.slice(index_arr[i]+sep.length, index_arr[i+1]));
  }
 }
 return (indexNames_arr);
};
 
//esempio di utlizzo stringTokenizer("Stringa da tokenizzare","stringa separatore")
 
trace(stringTokenizer("biibiibii||bellabella||nananana||testeteste", "||"));
 
//output: biibiibii,bellabella,nananana,testeteste

(Nessun voto)
Loading ... Loading ...

Inserisci il tuo Commento:

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a