Posted By

Waltem on 10/10/15


Tagged

actionscript String


Versions (?)

AS String


 / Published in: ActionScript 3
 

String edit/replace

  1. var myText:String = "Lorem-ipsum-dolor-sit-amet.";
  2. var newString:String = myText.split("-").join(" ");
  3. trace(newString); // Lorem ipsum dolor sit amet.
  4.  
  5. var someString:String = "_file";
  6. trace(someString.substr(1));// ouptut: file
  7.  
  8. var str:String = "Hello from Paris, Texas!!!";
  9. trace(str.substr(11,15)); // output: Paris, Texas!!!
  10. trace(str.substring(11,15)); // output: Pari
  11.  
  12. trace(str.slice(-3,str.length)); // output: !!!
  13. trace(str.slice(-8,-3)); // output: Texas
  14.  
  15. var queryStr:String = "first=joe&last=cheng&title=manager&StartDate=3/6/65";
  16. var params:Array = queryStr.split("&", 2); // params == ["first=joe","last=cheng"]

Report this snippet  

You need to login to post a comment.