in reply to how to find substring using regex

Why would you expect the count to be more than one, when there's only one instance of what you're matching?

UPDATE: OP has been edited without notice since this reply and the others to date. Original code (with code tags added by /me) was:

$cnt =0 $str="hi hi harshmane hi hi"; if ($str=~/([harsh]+)/g) # cf current content { $cnt++; } print $cnt;

OP has been msgd that such changes without notice are unhelpful.

Replies are listed 'Best First'.
Re^2: how to find substring using regex
by Argel (Prior) on Jun 23, 2011 at 16:16 UTC
    I think he did the same thing in to find string. And this question is virtually the same as that one. That might also explain why he only matches once in this thread -- he probably used different data in the other one.

    Elda Taluta; Sarks Sark; Ark Arks
    My deviantART gallery