$s = "***ab***c";
$s =~ s/\*([^\n])/\*\n\1/ for 1 .. 2;
print $s;
Output was:
*
*
*ab***c
Since you know the state it's going to be after it's changed, you can include that in the regex. Hence *, not followed by \n will match, along with the for loop suggested earlier, gives you your count. Using \1 here just puts the next value (after the matched *) back into the string.
Update: markkawika's comment might be below threshold, so I'll add it here as well, since his regex is better than mine.
Suggested regex: s/\*(?!\n)/*\n/ |