Awk regular expressions

Hi Experts,

Can you please help me out for the below scenario,

I have a variable length file with the fixed number of columns, in which the fields are delimited by pipe symbol (|). From that file I have to extract the lines which has the following scenario,
The field1 in a line should have the field2 as its part.
For example,
sample.out
A123(BCD)|BCD|DEFGH||WE|
C234|54CD|DFVCSE|W|TY|

From the above sample file, I have to extract the line A123(BCD)|BCD|DEFGH||WE| , in which the field1 has the value of field2 enclosed in brackets.

Hope I am clear.

I have tried using awk -F'|' '{if( $1 ~ /$2/ ) {print $0;}}' sample.out
This is not working for me.

Kindly help me out for this.

Thanks in advance,

Chella.

Try this:

awk -F"|" '$1 ~ $2' file

Regards