Variable regular expresion in awk.

:confused:
Is there any way to use in awk a regular exprexion with a format not previusly known?
I mean something like /VAR/ ,obviously VAR is the variable exprexion.

Thak you all in advance.

Do you mean this?

identifier_regexp = "[A-Za-z_][A-Za-z_0-9]+"
$0 ~ identifier_regexp

You can sprintf a complex string as an regexp or however you care to set it up....

hi Jim that�s a good idea , however in gonna post an ex. to show you a clear image of what i�m trying.

I need this result:

$ echo ""|awk 'BEGIN{line="exec> ${TRAZA} 2>&1";file="/$NINN/jj/fgagfsa"}END{gsub(/TRAZA/,file,line);print line}'
exec> ${/$NINN/jj/fgagfsa} 2>&1

but i need to use this structure :frowning: :

$ echo ""|awk 'BEGIN{line="exec> ${TRAZA} 2>&1";file="/$NINN/jj/fgagfsa";reg_exp=TRAZA}END{gsub(reg_exp,file,line);print line}'  
/$NINN/jj/fgagfsae/$NINN/jj/fgagfsax/$NINN/jj/fgagfsae/$NINN/jj/fgagfsac/$NINN/jj/fgagfsa>/$NINN/jj/fgagfsa /$NINN/jj/fgagfsa$/$NINN/jj/fgagfsa{/$NINN/jj/fgagfsaT/$NINN/jj/fgagfsaR/$NINN/jj/fgagfsaA/$NINN/jj/fgagfsaZ/$NINN/jj/fgagfsaA/$NINN/jj/fgagfsa}/$NINN/jj/fgagfsa /$NINN/jj/fgagfsa2/$NINN/jj/fgagfsa>/$NINN/jj/fgagfsa&/$NINN/jj/fgagfsa1/$NINN/jj/fgagfsa

Any ideas?
Thx

not following the entire code, but...... you can pass shell environment variables like so:

echo ""|nawk -v traza="${TRAZA}" 'BEGIN{line="exec> " traza " 2>&1"; .......

Yes I know but i was trying to do the all thing in awk.
Anyway thx mate.