Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: how to to find the "/" in a string

by philiprbrenan (Monk)
on Aug 31, 2012 at 21:39 UTC ( #991093=note: print w/replies, xml ) Need Help??


in reply to how to to find the "/" in a string

Here is a start. The regular expression gets the size of the array returned by the regular expression, which uses () to enclose the text to be searched for and /g to find all the occurences.

use feature ":5.14"; use warnings FATAL => qw(all); use strict; my $h = "aaa bbb ccc aaa aaa"; say scalar (() = $h=~m(aaa)g);

Produces

3

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991093]
help
Chatterbox?
[perldigious]: As long as you are a good "boy scout" stevieb, more power to you... but I like my Jeep, and don't like the idea of rolling it or crashing it in to anything. :-)
[thezip]: Me, not as much.
[perldigious]: Mine too thezip, especially my German Shepherd. He looks like he is about to die of heat exhaustion all summer, so he goes nuts when winter comes and he can play in the snow.
[stevieb]: my main off-road vehicle nowadays is a strengthened mercedes ML320. I'm very hard on it, but I've never had any real issues at all (I love how small and light it is, and it has a very, very good centre of gravity for how I roll)
[perldigious]: "for how I roll"... ahhh, I see what you did there stevieb.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2016-12-06 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.