in reply to Simple regex related problem

The length-based approaches are probably a bit faster, but this also seems to work:

>perl -wMstrict -le "my $s = qq{\t\t\tX\t\t}; my $n =()= $s =~ m{ \G \t }xmsg; print $n; " 3

Update: Removed pointless capture group from regex.