Take this string as input:
string s="planets {Sun|Mercury|Venus|Earth|Mars|Jupiter|Saturn|Uranus|Neptune}"
How would I choose randomly N from the set, then join them with comma. The set is defined between {} and options are separated with | pipe.
The order is maintained.
Some output could be:
string output1="planets Sun, Venus";
string output2="planets Neptune";
string output3="planets Earth, Saturn, Uranus, Neptune";
string output4="planets Uranus, Saturn";// bad example, order is not correct
Java 1.5