Hi,
I have to read in a file that contains a number of coordinates. The file is structured in the following way:
X1/Y1,X2/Y2,X3/Y3,X4/Y4
Where X and Y are positive integers. To solve this problem I want to use a regex (I think this is in general a good idea because of minimal refactoring when the pattern changes).
Therefore I have developed the following regex:
Regex r = new Regex(@^(?<Coor>(?<X>[0-9]+)/(?<Y>[0-9]+))(,(?<Coor>(?<X>[0-9]+)/(?<Y>[0-9]+)))*$");
However when I test this regex on data, for example:
1302/1425,1917/2010
The Regex only seems to recall the last X, Y and Coor group. In this case Coor is "12/17", X is "1917" and Y is "2010". Is there a way to generate some sort of tree. So I find an object who gives me all the Coor expressions, with under each Coor an X and Y component?
If possible, I would like to use only one Regex, this because the format could perhaps change to another one.