Enter your email address:

    Delivered by FeedBurner

Wednesday, December 10, 2008

Actionscript: Get Substring

The sample code below gets the substring of any given string.

var s:String = "abc-def";

var controlno1:int;
var controlno2:int;

controlno1 = s.substring(0, s.indexOf('-'));
//result = "abc"

controlno2 = s.substring(s.indexOf('-')+1, s.length);
// result = "def"


s.substring(beginindex,endindex)
Get the substring based on a given string. 0 being the first position.


s.indexOf(string)
Get the position of a character/string on a given string. Result = -1 if the string to find is not found.

2 comments:

iceah said...

first time ko dito mare c: maraming matututo dito pero wla akong patience dyan si Pasti lang c:

Marilou / Lucky Cow Shop said...

hehehe programming kc ito eh, taguan ko talaga ng source code

Post a Comment

About Me

My photo
I provide health supplements, adult wellness products, glutathione, and other merchandise. Please visit my online shop at: http://luckycowshop.blogspot.com/