String indexOf() method example:-
String class method indexOf() is use to find the starting character position of the substring from the string. The indexOf() method start to search from beginning of the string and matching the substring from substring, if substring is match then it return a index position of the starting character of the substring within string.
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 stringposition:Number = str.indexOf("In");textcontrol1.text = str; textcontrol2.text = String(stringposition); } ]]> </fx:Script> <s:Panel width="250" height="250" title="String indexOf() method example" backgroundColor="0xEEFFEE"> <s:VGroup> <mx:Text text=" Main String" fontSize="12" fontWeight="bold"/> <mx:Text id="textcontrol1"/> <mx:Text text="String position" fontSize="12" fontWeight="bold"/> <mx:Text id="textcontrol2"/> </s:VGroup> </s:Panel></s:Application> |
Output:-

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.