Perl recursive regular expression

Hi,
How can I do recursive pattern match in perl with regular expression.
I have file with record like below.

pravin test1 test2 pravin test3 test5 test99 pravin test88

desire o/p

pravin pravin pravin

Try:

perl -lne '$,=" ";print /pravin/g' file

Hi bartus11,

Thanks. Is there any way with regular expression ? Without changing $, ?

It is using regular expression: /pravin/g. $, is used just to format the output properly.

1 Like