String manipulation - functions (edited title)

I don’t know if it’s possible but i would like to take the first, and the last letter from a word and compare it, it would be very usefull to me, please help me

There are a few String methods you can check in the Actions Panel > Function > String.\rAbout your problem, let’s say you have a DYNAMIC text box on the scene that you called “text”, with the word “Salut” in it. If you put this code in teh first frame of the timeline :

 a = text.length ;\r\rb = text.charAt(0) ;\r\rc = text.charAt(a-1) ;\r\rtrace (a) ;\r\rtrace (b) ;\r\rtrace (c) ;

you’ll get 5, S, t.\r\rpom 0]

More about Strings methods. Let’s say that your Dynamic Textbox ‘text’ now contains “azertyuitop”.

   trace (text.substr (2,3)) ;\r\r//returns 'ert' that is to say 3 letters from the letter indexed as 2, that is to say the \r\r//3rd because the index start from 0\r\r\r\rtrace (text.substring (2,4)) ;\r\r//returns 'er' that is to say letters from index 2 to 4-1. That's how it works, don't ask me why.\r\r\r\rtrace (text.indexOf ("t")) ;\r\r//returns 4 -> first instance of t.\r\r\r\rtrace (text.lastIndexOf ("t")) ;\r\r// returns 8, the last index of the string

pom 0]