Home Tutorial Flex Flex4 Components String substring method example

 
 

String substring method example
Posted on: June 4, 2010 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for String substring method example:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 4, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com