"Harry Truax" <htruax / stf.com> writes: > Hi, > > I am working on a project which involves reading lines from a file, one by > one, looking for certain patterns in each line, converting the patterns into > new > ruby code which may use some of the info in the recognized patterns. I think > this would be a good application for Ruby's built in regular expression and > pattern/substitution abilities. I would greatly appreciate any advice on a > nifty way to approach this. I have some examples of what I want to do below: > > Input from my source file: > > box2_34 = $CUR % ((box2_20 + (box2_21) + box2_22) - (box2_25 + box2_27 + > box2_29 + box2_31 + box2_33)) > > Convert the above to: > > box2_34 = $CUR % (box2_20.to_f + box2_21.to_f + box2_22.to_f - (box2_25.to_f > + box2_27.to_f + box2_29.to_f + box2_31.to_f + box2_33.to_f)) Would it maybe easier to write a Domain-Specific Language and then simply eval the source file? The input looks to me like syntactically correct Ruby... > I have a start on this, but if anybody has a handy way to do/approach this I > would sure appreciate any input. > > Thanks alot, > > Harry Truax -- Christian Neukirchen <chneukirchen / gmail.com> http://chneukirchen.org