I have a set of items that I want to put in an string but i don't know the order or the right format, and I am letting the "user" define this configuration, then I want to parse this expression and return an string given a set of objects.
examples...
given the set of elements [a1, a2, a3, a4] and some expressions
"Printing items: (item)[0] (, item)[2,n-1] and (item)[n]"
produces
"Printing items: a1, a2, a3 and a4"
Another example:
"Another way: we have (item)[0] and {n-1} others (</br> item)[2,n-1] </br> and (item)[n]"
results is
Another way: we have a1 and 3 others
a2
a3
and a4.
I have employed a custom notation, but maybe there is something out there that can help me or maybe an standard notation already done for this. Any ideas? What the best way of approaching to a solution.
Thanks.