use var in gsub of awk

Hi all,

This problem has cost me half a day, and i still do not know how to do.
Any help will be appreciated. Thanks advance.

I want to use a variable as the first parameters of gsub function of awk.

Example:

{
...
arr[i]=gsub(i,tolower(i),$1)
(which should be ambraced by //)
...
}

You can use a variable as the first argument passed to gsub:

% echo a|awk '{gsub(x,"b")}1' x=a       
b

P.S. As you probably already know, gsub function returns the number of substitutions made, so:

% echo "a a"|awk '{v=gsub(x,"b");print v}' x=a
2