A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: delete a character from a string

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    32
    ello string specialists

    i have a variable called names wich displayed in a box result as :

    steven,frank,mark,john yes it's from an array

    now tell me plz how to remove the , from it.
    i try some search and convert but it doesn't work out for me :/

    thx in advance

  2. #2
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    The "proper" way is to use the String.functions but apparently there pretty slow so heres what i think;
    newString="";
    for(i=1;i<(length(names)+1);i++) {
    c = substring(name,i,1);
    if (c != ",")
    newstring = newString + c;
    }
    names=newString;
    Hope this helps;


  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    32
    i just love flashkit

    it worked like a charm mrBlinKoK
    thx alot!!

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Location
    las vegas,nv
    Posts
    694
    Strings have a built-in length property so in the future you can use the charAt() function to evaluate characters using a loop and then do what's needed.

    example:

    for(i=0;i<yourString.length;i++){
    if(yourString.charAt(i)=="whateverYouWantHere"){
    doSomethingHere;
    }
    }

  5. #5
    Member
    Join Date
    Jan 2001
    Posts
    32
    Just liked to say there is an 'so' easy to use method.

    var names = namesarray.join("<BR>");

    so when var names wil be show in a txtbox with HTML allowed it wil present the array as

    name1
    name2
    name3

    thx for the help and maybe it helped others as well :/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center