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
In reply to Re^2: how to find substring using regex
by johngg
in thread how to find substring using regex
by harshmane
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |