Substitute all matches with values in Ruby regular expression
- by Lewisham
Hi all,
I'm having a problem with getting a Ruby string substitution going. I'm writing a preprocessor for a limited language that I'm using, that doesn't natively support arrays, so I'm hacking in my own.
I have a line:
x[0] = x[1] & x[1] = x[2]
I want to replace each instance with a reformatted version:
x__0 = x__1 & x__1 = x__2
…