Posted By

adrianparr on 03/17/10


Tagged

substr character String last char as3


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

socialflasher
adrianparr
tspitzr


AS3 Get the Last Char in a String


 / Published in: ActionScript 3
 

Returns the last character is a string.

  1. function getLastCharInString($s:String):String
  2. {
  3. return $s.substr($s.length-1,$s.length);
  4. }
  5.  
  6. trace(getLastCharInString("abcdefg"));
  7.  
  8. // OUTPUT
  9. // g

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: marcelodeassis on July 21, 2012

I preffer using myString.slice(-1);

You need to login to post a comment.