Home Tutorial Flex Flex4 Components String substring method example

 
 

String substring method example
Posted on: June 4, 2010 at 12:00 AM
In the Action Script3, substring are sequential characters that are found from a string. String class provide methods for finding substring from string.

String substring() method example:-

In the Action Script3, substring are sequential characters that are found from a string. String class provide methods for finding substring from string. Method substring(int, int ) takes two integer type parameters, first is starting index position of the sub string and second is end index position of the sub string. In this example we have used this method.

Example:-

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init();">

<fx:Script>

<![CDATA[

private function init():void{

var str:String = "Rose India";

var substring:String = str.substring(5,13);

textcontrol1.text = str;

textcontrol2.text = substring;

}

]]>

</fx:Script>

<s:Panel width="250" height="200" title="String substring() method example" backgroundColor="0xEEFFEE">

<s:VGroup>

<mx:Text id="textmsg1" text=" Main String" fontSize="12" fontWeight="bold"/>

<mx:Text id="textcontrol1"/>

<mx:Text id="textmsg2" text="Sub String" fontSize="12" fontWeight="bold"/>

<mx:Text id="textcontrol2"/>

</s:VGroup>

</s:Panel>

</s:Application>

Output:-

Download this code

Related Tags for String substring method example:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.