I have a string that comes to me in JSON with data like this
{"name":"AMD","history":{"2019-09-05":{"open":"31.79","close":"31.50","high":"32.05","low" :"31.12","volume":"57693493"},"2019-09-04":{"open":"31.32","close":"30.95","high":"31.83","low" :"30.85","volume":"46709780"},"2019-09-03":{"open":"30.83","close":"30.90","high":"31.14","low" :"30.68","volume":"38080254"}, ... etc
wearing
string[] cotizacion = Regex.Split(cadena_url, @"\d{4}\-\d{2}\-\d{2}");
It correctly generates an element in the quotation array for each day, the problem is that the split eliminates the date and I am interested in keeping the date and adding it to the array.
I can't add the date to the array.
Thank you very much for the help.
That regular expression finds the dates in the string, but to capture them you must transform the expression into a capture expression (
"(\d{4}-\d{2}-\d{2})"
) (note the parentheses inside the expression) and iterate through each capture:Assuming you have a class to capture the data:
It shows the following output: