This is true but beware of a bug in 7.0.14  player which causes a replace at 
the very end of the string to fail when doing it this way.
 
The bug is related to a different behaviour in thesplit method which fails to 
divide the string into ie. two pieces when the phrase is at the very end of the 
string. I solved it by allways add an extra unique char sequence to every 
string that I wanted to do a replaceon.
 
Below is my bullet proof version:-)
 
/**
  Searches a sTxt for sFind and replaces sFind with sReplace
 */
public static function replace(sTxt:String,sFind:String,sReplace:String, 
b:Boolean) {
  //Fix bug in fp 7.0.14 by adding a random char sequence in the end 
  //of the string and then remove it again before returning 
  sTxt += "|?*";
  var sChanged:String = sTxt.split(sFind).join(sReplace);
  return sChanged.substr(0, sChanged.length - 3);
  
}
 
 
If you don't support player 7 you don't need to worry ;-)
 
 
/Martin Baltzer

________________________________

Fra: [EMAIL PROTECTED] på vegne af JesterXL
Sendt: lø 03-12-2005 20:12
Til: Flashcoders mailing list
Emne: Re: [Flashcoders] Split String



str = "hello/this is a new line/and so is this";
str  = str.split("/").join("\n");

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, December 03, 2005 2:15 PM
Subject: [Flashcoders] Split String


Can anyone point me in the right direction on how to split a string using a
special character(/).  this is my first line / this is my second line /
etc...


Thanks!

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to