Amatuer programmer here, just need some help inserting a * between a

coefficient and a variable to later be evaled. Need some help

referencing back to the (\d+) the number in front of a variable. Also

need to do this with )( inserting a * in between them. Any help would be

great.

equation = “5x”

if equation =~ /(\d+)x/

equation =equation.gsub((/(\d+)x/),(\1 + “*” + “x”))

end

On Thu, Jan 26, 2012 at 11:15 PM, Sathya L. [email protected]

wrote:

Amatuer programmer here, just need some help inserting a * between a

coefficient and a variable to later be evaled. Need some help

referencing back to the (\d+) the number in front of a variable. Also

need to do this with )( inserting a * in between them. Any help would be

great.

equation = “5x”

if equation =~ /(\d+)x/

equation =equation.gsub((/(\d+)x/),(\1 + “*” + “x”))

equation.gsub((/(\d+)x/), ‘\1*x’)