note
merlyn
I'd attempt this, but your specification is inconsistent, and as I was looking at it, I stopped working on it until you clarify. Specifically:
<blockquote>
<ul><li>The order of variables in the output string had to be the same as the input string.</ul>
</blockquote>
This specification cannot be used with your sample data because you have the items delivered in different orders in the subexpressions:
<code>(abdc)</code> vs <code>(adc-b)</code>. So are you saying:
<ol>
<li> that we're permitted to select a subexpression at random with which to comply, or
<li> that your sample data would never be the actual data, or
<li> that this rule can be tossed out?
</ol>
(Each of those yields a slightly different solution in my mind, because I can optimize for some things differently in each. {grin})
<p>-- <a href="http://www.stonehenge.com/merlyn/">Randal L. Schwartz, Perl hacker</a></p>
41235
41235