Visualizzazione dei risultati da 1 a 6 su 6

Discussione: funzioni su stringhe

  1. #1

    funzioni su stringhe

    scusate dove posso trovare dei tutorial di actionscript per flash?

    in particolare mi interessa vedere quali sono le funzioni che posso fare su una stringa
    grazie e ciao a tutti

  2. #2
    fai prima a dire qual'è la tua esigenza, cioè che ti serve di fare con una stringa

    Ciao

  3. #3
    beh ad esempio:

    -substring ho trovato
    -lenght ok
    -trim

    -posizione di occorenza di un carattere in una stringa?
    esempio:
    stringa=prova.test
    char='.'
    pos=funzioneXX(stringa,char);
    risultato= 5(pos)

  4. #4
    codice:
    function cerca(stringa,car)
        L=stringa._lenght
        R=0
        P=0
        if(L>0){
                for(I=1;I<=L;i++){
                      if(substring(stringa,I,1)==car){
                             R+=1
                             P=I+"; "
                       }
                 }
         trace("ripetizioni"+R)
         trace("posizione del carattere "+P )
    }
    stringa = "il mio cane è bello!"
    car = "è"
    cerca(stringa,car)
    Oppure (by IroN@xiD)

    codice:
    function findStrPos(my_str,find_str) {
      var start_idx=0, posizione=[], tmp;
      while((tmp=my_str.indexOf(find_str, start_idx))!=-1) {
    	posizione.push(tmp);
        start_idx=tmp+find_str.length;
      }
      return posizione;
    }
    
    
    Ecco come usarla 
    
    str="pippo pluto pippo pluto pluto pippo";
    var findpos=findStrPos(str,"pippo");
    //stampiamo le posizioni individuate
    for(x=0;x<findpos.length;x++) trace(findpos[x]);
    oppure (by Andr3a)

    codice:
    se non ti servono le posizioni ma un highligh o il numero di occorrenze puoi usare questa 
    
    occorrenze = testo.split(parola).length - 1; 
    
    oppure 
    
    
    testo = testo.split(parola).join(''+parola+'');



    Se hai F7

    codice:
    TextField.replaceText()
    Availability
    
    Flash Player 7.
    Usage
    
    my_txt.replaceText(beginIndex:Number, endIndex:Number, text:String) : Void
    
    Description
    
    Method; replaces a range of characters, specified by the beginIndex and endIndex parameters, in the specified text field with the contents of the text parameter.
    Example
    
    The following example creates a text field called my_txt and assigns the text dog@house.net to the field. The indexOf() method is used to find the first occurrence of the specified symbol (@). If the symbol is found, the specified text (between the index of 0 and the symbol) replaces with the string bird. If the symbol is not found, an error message is displayed in the Output panel.
    
    this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 22);
    my_txt.autoSize = true;
    my_txt.text = "dog@house.net";
    
    var symbol:String = "@";
    var symbolPos:Number = my_txt.text.indexOf(symbol);
    if (symbolPos>-1) {
       my_txt.replaceText(0, symbolPos, "bird");
    } else {
       trace("symbol '"+symbol+"' not found.");
    }

    insomma basta fare unapiccola ricerca

  5. #5
    caspita!!! mi bastava anche meno

    grazie

  6. #6

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.