I'm not to good in Regular Expressions. I have
string rgba = "[0.123,0.223,0.2,1]";
What would be the best way to covert it into double[] ?
rgba.Replace("]", String.Empty)
.Replace("[", String.Empty)
.Split(',')
.Select(double.Parse)
.ToArray();
Or if you know that it will always start with [ and end with ]
rgba.Substring(1, rgba.Length - 2)
.Split(',')
.Select(double.Parse)
.ToArray();
And if you don't like LINQ
Array.ConvertAll(rgba.Substring(1, rgba.Length - 2).Split(','), double.Parse);
Regex is quite expensive to use, and I wouldn't recommend it in this case.
[0.1, 1.0, 0.5, 1 ]