void JSONIntoShareData(string id, string filecontent, ShareData sd) { Match chartpointmatch = Regex.Match(filecontent, @"WSOD.InteractiveChart.SetChartPoints\((.+?)\)"); if (chartpointmatch.Success == false) { ErrorJSON("no datapoints in " + id); return; } string outerdata = chartpointmatch.Groups[1].Value; bool success; MatchCollection mm = Regex.Matches(outerdata, @"\\""(.+?)}"); foreach (Match mmm in mm) { string extractedline = mmm.Groups[1].Value; MatchCollection line = Regex.Matches(extractedline, @":\\""(.+?)\\"""); string date = line[0].Groups[1].Value; string open = line[2].Groups[1].Value; // [1] is UK date, [2] is descriptive date string high = line[3].Groups[1].Value; string low = line[4].Groups[1].Value; string close = line[5].Groups[1].Value; // is adjusted string volume = line[6].Groups[1].Value; success = sd.AddDataPoint(date, open, high, low, close, volume); if (success == false) ErrorJSON("duplicate data " + date + " " + sd.symbol); } mm = Regex.Matches(filecontent, @"~overlayEvent_~(.+?)\.replace(.+?)\.replace"); foreach (Match mmm in mm) { Match datematch = Regex.Match(mmm.Groups[2].Value, @"~overlayDate_~\\u003e(.+?)\\u003c"); string date = datematch.Groups[1].Value; Match opmatch = Regex.Match(mmm.Groups[2].Value, @"~header_~\\u003e(.+?)\\u003c"); string op = opmatch.Groups[1].Value; //MatchCollection values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\.\\u003c"); // \u003e\u003cdiv\u003e1.00 in PCT.\u003c, \u003e\u003cdiv\u003e0.3812 in USD.\u003c // earnings // split // dividend // stock dividend MatchCollection values; if (op == "Earnings" || op == "Split") values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\\u003c"); else values = Regex.Matches(mmm.Groups[1].Value, @"\\u003e(.+?)\.\\u003c"); foreach (Match value in values) { string opext = value.Groups[1].Value; opext = opext.Replace(@"\u003c", ""); opext = opext.Replace(@"\u003e", ""); opext = opext.Replace(@"div", ""); string[] splits = opext.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (splits.Length == 3) // ex 1.00 in PCT. { if (splits[2].IndexOf("PCT") != -1) success = sd.AddEvent(date, op, splits[0], "PCT"); else success = sd.AddEvent(date, op, splits[0], splits[2].Replace(".", "")); } else // no currency - earnings - probably in USD success = sd.AddEvent(date, op, splits[0], "N/A"); if (success == false) ErrorJSON("duplicate event " + date + " " + sd.symbol); } } }