Re: Trying to use gsub using variables

----- Original Message ----

y = TEST
you meant, didn’t you?

x = “time”
y = ‘TEST’

acl.gsub(/x/,y)

How do I get gsub to use the value of x rather “x” itself in my match?

You can use the #{ruby code} notation that evaluates the ruby code and
inserts
the value like in double quoted strings.
In your case that would be something like:

acl.gsub(/#{x}/,y)

Though the content of x should not be interpreted, you should write:

acl.gsub(/#{Regexp.escape(x)}/,y)

thanks

you are most welcome,

Christophe