Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(zdog) Re: how to get the number of times a pattern matched

by zdog (Priest)
on Jun 02, 2001 at 00:43 UTC ( #85070=note: print w/ replies, xml ) Need Help??


in reply to how to get the number of times a pattern matched

The pattern matching function m// should return the number of times the pattern matched.

Update: Wups. My mistake. Nevermind.

Update 2: However, s/// does what I thought m// does, so you can do something like:

my $count = ($string =~ s/(pattern)/$1/g;)

Good luck.

Zenon Zabinski | zdog | zdog7@hotmail.com


Comment on (zdog) Re: how to get the number of times a pattern matched
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://85070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-08-22 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (164 votes), past polls