I would like to eval() the following text:
(2, [(3, 4), (5, 6)])
in Java, into some objects I defined, so let's assume:
new Pair(1, new ArrayList<Pair>({new Pair(3,4), new Pair(5,6)}))
What is the strategy to achieve so? The idea is that I could get any of the following:
(2, [(3, 4), (5, 6), (5, 6)])
(2, [(3, 4), (5, 6)])
(2, [(3, 4)])
Should I match it with regular expressions?
This is my attempt:
/\(([0-9]+), \[(?:\(([0-9]+), ([0-9]+)\)(?:, )?)+\]\)/
Aucun commentaire:
Enregistrer un commentaire