String class method indexOf() is use to find the starting character position of the substring from the string.
String class method indexOf() is use to find the starting character position of the substring from the string.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[ textcontrol1.text = str; textcontrol2.text = String(stringposition); } ]]> </fx:Script> <s:Panel width="250" height="250" title="String indexOf() method example" backgroundColor="0xEEFFEE"></s:Application> |
Output:-
