This method takes two integer parameters, first is starting character position and second is length of the substring.
This method takes two integer parameters, first is starting character position and second is length of the substring.String substr() method example:-
String class provides substr() method for find substring from string. This method takes two integer parameters, first is starting character position and second is length of the substring.
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[ textcontrol1.text = str; textcontrol2.text = substring; } ]]> </fx:Script> <s:Panel width="250" height="200" title="String substr() method example" backgroundColor="0xEEFFEE"></s:Application> |
In this example, we have used this method with a string as "Rose India New Delhi" and find string that starting character position is 8 and length of the substring is 3.
Output:-
