Finding a word through substring in a file

I have a text file that has some data like:

PADHOGOA1 IOP055_VINREG5_1 ( .IO(VINREG5_1), .MONI(), .MON_D(px_IOP055_VINREG5_1_MON_D), .R0T(px_IOP054_VINREG5_0_R0T), .IO1() );

PADV30MA0 IOP056_VOUT3_IN ( .IO(VOUT3_IN), .V30M(px_IOP056_VOUT3_IN_V30M));

PADV30MA0 IOP057_VOUT3_OUT ( .IO(VOUT3_OUT), .V30M(px_IOP057_VOUT3_OUT_V30M) );

PADV15MA0 IOP059_VOUT15_OUT ( .IO(VOUT15_OUT), .V15M(px_IOP059_VOUT15_OUT_V15M) );

PADHOGOA1 IOP064_VREFLB ( .IO(VREFLB), .MONI(), .MON_D(px_IOP064_VREFLB_MON_D), .R0T(px_IOP064_VREFLB_R0T), .IO1() );

My substring is .V30M
I am find this substring and want to display the whole word.

Desired output:

.V30M(px_IOP057_VOUT3_OUT_V30M)

Please need some help.

Why doesn't .V30M(px_IOP056_VOUT3_IN_V30M)) show up in your desired output? Try

grep -o "[[:alnum:]]*\.V30[[:alnum:]()_]*" file
.V30M(px_IOP056_VOUT3_IN_V30M))
.V30M(px_IOP057_VOUT3_OUT_V30M)
1 Like

Or try:

grep -o '\.V30M([^)]*)' file