Pt Skaar wrote:However, I've been asked to modify the code so that it will allow for this possibility:
label=data, data1, (unknown number),label=data...etc.
What's happening is that an unknown element exception is being thrown on data1. Is there an easy way around this? Especially since the possibility of multiple entries exists in the first segment.
What, so you can have:
label=data1, data2...,label=data
but not:
label=data,label=data1, data2...
?
It seems to me like you're having to clear up somebody else's badly thought-out fudge. Why couldn't the format simply be:
label=data1[,data2...];label=data[,data2...];... (semicolons for separating labels, commas for separating data elements)
it'd be a lot easier, and you could then have multiple data items anywhere you like.
Either way, the answer to your question is: Yes.
If the answer to my first question is 'yes', I'd probably try something like splitting the line initially on the first
two "=" it finds (ie,
line.split("=", 3)).
That will give you three portions:
1. The first label name.
2. The first label data, plus the 2nd label name, separated by commas.
3. The second label data, plus any other labels in the line, separated by commas.
It should be a fairly simple matter then to cobble those back together into a set of "label=data" elements.
But, as I said, the only reason you need to do this at all is because somebody else didn't think through the problem.
Winston