I need to verify if a string is in the following format
{x:y} or {x,y,…,z} where x,y,z are either integers or doubles.
I was thinking I either need a reg-ex and/or an interpreter.
Does anyone know how to go about this?
Also suggestion to a library that does this would be deeply appreciated.
The second step would be having an interpreter that cand interpret expressions like this:
0.5*{0.4,0.6,0.7} -> {0.2,0.3,0.35}. I realize that the optimal approach would be to define a grammer for this that the interpreter can use.
Thanks,
B
Given that there are a 101 different double formats and Double.TryParse() is built into the .net framework.
I would use a regex or just string.split to get an array of strings that contains your “x,y,z” values then call Double.TryParse on each of the values.
As you have two possible formats, I would first check to see if the input string contains “:” then have separate code to split each format so as to make the code more understandable.