From: J-H Johansen Date: 2012-01-27T08:16:38+09:00 Subject: Re: Help with back references in regex On Thu, Jan 26, 2012 at 11:15 PM, Sathya Levy 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') > end > > -- > Posted via http://www.ruby-forum.com/. > -- Jens-Harald Johansen -- There are 10 kinds of people in the world: Those who understand binary and those who don't...