in reply to Re: how to find substring using regex
in thread how to find substring using regex

No need for the capture and substitution by itself!

knoppix@Microknoppix:~$ perl -E ' > $str = q{hi hi harshmane hi hi}; > $cnt = () = $str =~ m{hi}g; > say $cnt;' 4 knoppix@Microknoppix:~$

I hope this is of interest.

Cheers,

JohnGG