Search code examples
regexunity-game-engineunityscript

Is this regular expression?


This is how to split string in Unityscript from Unity Wiki. However, I don't recognize " "[0]. Is this regular expression? If so, any reference to it? I'm familiar with regular expressions generally and used them a lot, but this syntax is little confusing.

var qualifiedName = "System.Integer myInt";

var name = qualifiedName.Split(" "[0]);

Wiki Reference


Solution

  • As many have already mentioned, " "[0] is the first character of the " " string (which is a System.String, or an array of System.Chars. The problem with UnityScript is that ' ' is interpreted as a String too, so the only way to provide a Char is by slicing.