How do you text.split a string with no delimiters/separators? (UnityScript)


I have a string that I need to be split, so that each of the values can go into an array. Here is an example of it:



I tried using this code to put the values in an array.

var myTextFile  :  TextAsset;
    function Awake(){
    for (var x = 0; x< myTextFile.text.Length; x++){
    			    	if (myTextFile.text[x] != myTextFile.text[5]) {
    			    		if(myTextFile.text[x] != "


When reading the values, they are not integers. I did not parse them because I don’t know how to split it without any delimiters. (i.e String.Split(“”[0]) I always had to change it to put commas between the numbers and use “,” as a separator. Is there a way I can get around this?

Something like this(found in another answer):

 var lineArray : String [] = myTextFile.text.Split("

for ( var thisLine : String in lineArray ) {

        var numberStrings : String [] = thisLine.Split(""[0]);
        for ( var thisNumber : String in numberStrings ) {
            var someInt : int = int.Parse(thisNumber);

my workaround to this was to make the textFile toString. After that I just compared the string values to see if it matched.

myStr = myTextFile.text[x].ToString();

Not exactly an intArray anymore though. (stringArray)

Try something like this?

 import System.Linq;


 var intArray = myTextFile.text.Where(function(c) c != "

"[0]).Select( function(c) int.Parse(c.ToString())).ToArray();

You’re trying to put each number digit in an array?
“12345” → {“1”, “2”, “3”, “4”, “5”}

To do that:

var str : String = "12345";
var strArray : String [] = str.Split("");
var intArray : int [] ={return parseInt(x)});

Hope that helps.

Find here more about c# string split …String Split()