public static MultiPolygon FromString(string data) { MultiPolygon polygon = new MultiPolygon(); Regex regex = new Regex(@"[ \r\n\t]"); data = regex.Replace(data, ""); regex = new Regex(@"\[(.*?)\]"); MatchCollection matches = regex.Matches(data); string[] splitData = new string[matches.Count]; for (int i = 0; i < splitData.Length; i++) { splitData[i] = matches[i].Value.Substring(1, matches[i].Value.Length - 2); } foreach (string s in splitData) { regex = new Regex(@"\(?(.*?)\)"); ProcessingState state = new ProcessingState(); foreach (Match m in regex.Matches(s)) { Process(m.Value, ref state); } if (state.IsComplete()) { polygon.shapes[state.name] = new Polygon(state.vertices.ToArray()) { colourOutline = state.colour, scale = state.scale }; } } return(polygon); }