JavaScript String object usage in Unity? (Android build)

Hi!

I’m porting a few Javascripts from an existing project to unity (android build). This code uses the String object class a lot.
Then I realize that while Unity recognizes String as a data Type, most of the String methods are gone.

I need the methods: charAt, split, subString, match, and others, but none are available.

Maybe I just need to import the object class from the android SDK library?. Or use something similar?

I’m so lost. Help! :slight_smile:

Thanks in advance!

I use your first two String functions in an android build with JavaScript.

var sArray = myString.Split("|"[0]);

this line splits a long string separated with a ‘|’. For charAt I just use myString[0] for the first char of myString or myString[1] for the second. This caused an error because I couldn’t do anything with type char, so I changed it back to a 1 char String.

myString[charNo].ToString();

I hope this helps.

Re: String Object in Java Script
Hi,
The String object provides us some functionality to manipulate string according to requirement. We can use java script string function to concatenate to strings, to convert it in lower case and upper case, to find out substring and convert it to uppercase and lowercase… for more details check out the following url…
http://mindstick.com/Articles/ee5376d3-8b21-41a4-90b4-192f41f0ba6a/?Implementing%20String%20Object%20in%20Java%20Script

Thanks !!!