in reply to Re: Re: counting regex hits Benchamark
in thread counting regex hits

No regex required:
$strg = qq[This has- some- d-a-she-s -in it]; %cnt = (); @chrs = split('',$strg); foreach (@chrs) { $cnt{$_}++; } print qq[$cnt{'-'}\n];

Replies are listed 'Best First'.
Re*4: counting regex hits Benchamark
by Tomte (Priest) on Mar 19, 2003 at 09:17 UTC

    Why is this a reply to me?
    I do not get your point...

    ...but I "can't hold my water" anyways:
    If this is a reminder that I forgot in my (possibly silly ;-) benchmark a viable alternative, I assure you that a for-loop counting each characters occurences isn't a viable alternative if you're interested in /one/ character only, as is the OP. ¹

    kind regards,
    tomte


    ¹ silly me: ;-D

      Sorry I meant to reply to the initial question of the thread, not your response. Also I assumed that not invoking the regex engine would save execution time which is obviously incorrect.