Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if text “begin with” substring in Actionscript 3

How can I check if a text “begin with” substring in Actionscript 3 ??

Thanks a lot for help.

like image 424
Ahmed Ala Dali Avatar asked Dec 13 '22 02:12

Ahmed Ala Dali


1 Answers

There is an indexOf method: documentation.

It returns the first index of where the given string appears in the string that is searched. If this is not equal to 0, it doesn't start with the string. You can make the following function yourself:

function startsWith(haystack:String, needle:String):boolean {
    return haystack.indexOf(needle) == 0;
}
like image 67
MarioDS Avatar answered Feb 04 '23 20:02

MarioDS